lua-users home
lua-l archive

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


lua-bounces@bazar2.conectiva.com.br wrote:
> André de Leiradella wrote:
>> I've done it myself, and I'm not happy. I've seen how others did it
>> themselves, and I'm still not happy. Unless I'm missing something, I
>> don't see a way to get rid of the self local that must prefix every
>> property of the "class", making me write self.this and self.that. I
>> don't see an elegant way to call inherited methods like
>> super.something(...) or inherited something(...), but only hacks like
>> self.super.something(self, ...) or SuperClassName.something(self,
>> ...).
> 
> You can setfenv() the methods with a proxy table which looks for
> globals first in the object's method+attribute table before deferring
> to 'real' globals.  

Sure, thanks for opening my eyes. This will make "self" go away.

> Personally I think that self.something() / self.super.something() is
> clearer than 'something' implicitly coming out of the class's
> namespace.  A standardised object mechanism isn't likely to address
> such personal preferences.   

But right now you don't have the choice. You can write self.something(),
I can't write just something. But hey, setfenv can help me here too! The
only things left are private properties and call to inherited methods...
For the later I could make a super property of every instance and...
More on this later!

Thanks!

Andre de Leiradella