lua-users home
lua-l archive

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


Here's a variation of  your code using closures to create private
fields https://gist.github.com/762006
Notice that it pretty much makes the a.foo(a,...) and a:foo(...)
unecessary but I left it to conform with your example.

Additional reading on the subject can be done here:
http://lua-users.org/wiki/ObjectOrientationClosureApproach

PS.:

steve code using _newindex is quite interesting! Lua once again
surprises me (in a good way :)