lua-users home
lua-l archive

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

Of course, this all leads to the ulterior motive of making obj:method (...) more than just sugar for obj.method( obj, ... ).

The semantics of how to do that remain fuzzy and depend to some extent on the goals.

The simplest option is introducing a separate metatable entry which parallels __index but which will be used in preference to __index when doing method lookup. This alone makes it easier to implement properties/attributes on objects and catches many accidental uses of period rather than colon. But that then leads to questions such as whether there needs to be a corresponding method assignment metamethod and just how much complexity is warranted.