lua-users home
lua-l archive

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


> So, in my opinion, the primary advantages become:
>
> 1) Memory savings.  One table full of functions per unique object type.
> 2) Faster than the "index" tag method.
> 3) Easy to understand.
> 4) Every object type can have unified method calls made to it.
> 5) All the advantages described by Edgar months ago.
> 6) And most importantly, the existing interface is not broken.  Unified
> methods are only an addition to Lua.  If you don't use them, you don't
> see them.

Unified methods also allow you separate your data and your functions so you
don't get clashes. i.e. a table which is tagged to be a class cannot contain
data whose keys clash with function names.

See Python dictionaries emulation for an example:
http://lua-users.org/wiki/PythonDictionaries
and discussion (which probably needs tidying up!):
http://lua-users.org/wiki/ClassesAndMethods

Nick