lua-users home
lua-l archive

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


As I understood the original post, the question was not about
the use or function of the operator, but rather why "self" isn't
just passed all the time by the . operator or something, so
that you don't have to worry about it when coding.

Firstly, if this involved capturing the referenced object in a closure or something, this might also complicate things like 'caching' methods. For example:

   obj1 = blah(), obj2 = blah()

   obj1:func(...)
   obj2:func(...)

Can also be done as:

   obj1 = blah(), obj2 = blah()

   myfunc = obj1.func

   myfunc(obj1, ...)
   myfunc(obj2, ...)

I certainly rely on this behaviour for speed (bearing in mind that the obj1.func lookup may not be a trivial task depending on the metatable).


Secondly, it would be really nice if Lua settled down for a while; random syntax changes cause nothing but confusion and problems for existing applications.

Love, Light and Peace,
- Peter Loveday