lua-users home
lua-l archive

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


Hello,

For some time I have been trying to implement an object oriented structure
in my scripts. I've currently partly succeeded in this using the metatable
method of setting __index to the class an object is an intance of, and
__index of each class to its subclass.

My problem is that I currently have to use a lot of "self" references,
basically for every variable or function I access. My question is whether
this can be worked around, and what would be the best way. I would like the
following rules for variable lookup in a class method:

Look in:
1 - Function parameters
2 - Locally defined variables
3 - Current object variables or methods
4 - Globals

I'd appreciate any help.
Bjørn Lindeijer