[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: RES: RES: RES: idea of vision of blueprint of ROADMAP of Lua core
- From: Chris Pressey <cpressey@...>
- Date: Sun, 16 Jan 2005 19:10:06 -0800
On 17 Jan 2005 13:10:08 +1100
skaller <firstname.lastname@example.org> wrote:
> On Mon, 2005-01-17 at 04:17, Jay Carlson wrote:
> > How do you refer to object slots defined by parents?
> Inside the derived class it is easy:
> function derived (x)
> methods = base(x)
> --- this is the parent table
> super_meth1 = methods.meth1
> -- parent meth1
> methods.meth1 =
> ... super_meth1 (x) ...
> --- calls parent meth1
> -- override meth1
But how would you refer to a superclass's private instance variables?
'x' in your example is sort of a special case, since it's passed in the
constructor. What if base() defined a local y for its own use, and you
wanted to get at that?
It seems to come down to this:
K is an object.
K has some state.
K doesn't want things that use K to mess with K's state without K's
consent (whether this is done with accessor methods or metatables is
But subclasses of K sometimes need to mess with K's state directly in
order to extend K in some way.
I don't think this is a Lua-specific question at this point; any OO
language has to deal with this dilemma somehow.
The Lua way, as mentioned in (I think) PiL, is for K to just make its
state public and ask nicely that clients of K to please just not touch
While it doesn't appeal to the paranoid side of me that wants some
assurance of isolation between components, I can see a certain
minimalist elegance in it, befitting a language like Lua.