lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Sat, Nov 5, 2011 at 11:08 PM, HyperHacker <> wrote:
> I suppose you could take Roberto's example further and turn modules
> into "factories" of sorts:
> local foo = require('foo').create(some, args, here)
> so require('foo') just returns a function that will create an instance
> of the foo module. There might be a better name for this pattern?

That's no different from implementing a class in a module.  If you like,

  function new(name, ...) return require(name).create(...) end

  local afoo = new('foo', some, args, here)