lua-users home
lua-l archive

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


On Wed, Jul 22, 2009 at 7:14 PM, Wesley Smith<wesley.hoke@gmail.com> wrote:
> After reading module v. dofile discussion I was curious how people
> handle OO constructs as Lua modules.  I like having the module itself
> act as the "class" or "prototype" and use it as a constructor for an
> instance of that module or class.  For example, to support the syntax:

i do similar things too.  in short, anywhere you need a table with
functions, i arrange them to be callable in OO style (usually not
mandatory), and a nice way to write them is to just do a module.

in short, the more 'inline' syntax:

{ onefunc=function () .... end, otherfunc=function() ... end, ........ }

is nice only for a few small (mostly trivial) functions.  as soon as
you're wrapping significant functionality, it's better to write a
module.

-- 
Javier