lua-users home
lua-l archive

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

Arguments against:

* It's an addition. (The default position should generally be to say "no".)

* The semantics still need work. (Or at least say "not yet".)

Arguments in favor:

* It simplifies the implementation of objects with both methods and properties allowing method lookup to bypass a function call. (There was an alternate proposal a while back, I believe to allow a metatable entry that had to be a table and a fallback function beyond that.)

* It makes it possible to guarantee that methods are only invoked with their associated objects thereby avoiding certain bugs and/or security holes and/or the need for extra type-checking. This thereby also potentially speeds methods. For example, userdata methods using a __methindex table for exposing methods could safely access their data via:

	native_type* self = (native_type*) lua_touserdata( L, 1 );

* On a related note, it means that accidental uses of obj.method() instead of obj:method() will generally result in an error at the call site rather than further on when something is unhappy about the value of self.

Depending on the semantics chosen, it may or may not help with the case where there needs to be an overlap between the method namespace and the index namespace (e.g., for the Set class). (Another name for this proposal could be "separate namespaces for methods and keys" which feels odd to advocate for since I've long preferred LISP-1s to LISP-2s but the case here is a bit different.)