lua-users home
lua-l archive

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

On Wed, Mar 31, 2010 at 12:52 PM, steve donovan
<> wrote:
> On Wed, Mar 31, 2010 at 6:46 PM, Javier Guerra Giraldez
> <> wrote:
>> if all you want is encapsulation, polymorphism
>> and nice syntax, then you don't need any of "several competing
>> options".
> OK, but you have to get into metaprogramming fairly quickly - and from
> that sentence, I don't know which Lua OOP model you're thinking about
> ;)  It's probably the standard 'metatable.__index == metatable' but
> maybe not....

the beauty is that it doesn't matter!  as long as your 'methods' are
functions that accept the 'object' as the first parameter, and are
accessible with table lookups (either directly, or with metatables),
you can use the obj:mth(parms) syntax.

that's why i don't buy the "we need to standardize!" cries.  all of
the 'extra' "OOP models" support this syntax, making interoperability
mostly seamless.  and useless too, since i still haven't seen one that
gives any real advantage.  i find far easier to do it by hand in the
very (very) few places where i've needed some inheritance.  in most
cases simply using the module itself as the 'class' even takes most of
the metatable handling out of sight.