lua-users home
lua-l archive

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


PA wrote:
One thing that I like with this approach is that, beside providing encapsulation, it provides, er, "visual encapsulation". In other words, the entire object is defined inside one function. This is pretty neat :)
...
anObject = MySubclass()
anObject.description()

that is *very* neat. i have a conceptual version using a 'class' userdata, where you would say

require "class"
local animal = class{ table describing class : functions and methods}
local cat = animal{local attribs etc}

simply because userdata functions always call __index, so read-only is the default.

but your way is better.

Adrian