lua-users home
lua-l archive

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


on 1/25/05 11:53 AM, PA at petite.abeille@gmail.com wrote:

> For example:
> 
> // Root class
> 
> function LUObject()
>    local self = {}
> 
>    local description = function()
>    print "default description method"
>    end
> 
>    return
>    {
>    description = description
>    }, self
> end
> [ and more ]
> 
> Would the above scheme provide both inheritance and encapsulation
> without too much fuss?

Yes, but at a fairly high cost per object since every method has to be
instantiated and stored into the public table.

Mark