[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Some ways to get encapsulation in Lua
- From: Mark Hamburg <mhamburg@...>
- Date: Tue, 25 Jan 2005 18:16:53 -0800
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