lua-users home
lua-l archive

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


My problem with an extension to put method lookups into essentially their own namespace is that the full semantics and consequences still need to be worked out.

I have no problem with saying that the colon operator is not just syntactic sugar but rather is the official way to send a message to an object in Lua. That doesn't mean a change needs to or should break existing object implementations. It just means that one may be able to implement objects in other ways and that objects implemented in those ways won't be amenable to method lookup independent of the colon operator. One does need to introduce replacement mechanisms, but those are useful anyway,

What I like about moving method lookup into a separate namespace is that it allows for fast method dispatch combined with virtual property support. (The proposal to pass __self to __index and __newindex would also handle this.)

What I like more is that it catches more cases of obj.method() being used in place of obj:method() at dispatch time rather than down the road when something notices that a parameter has the wrong type.

What I really like about moving method lookup into a separate namespace is that it makes it much easier to build safe object implementations because the runtime will guarantee that method functions will only be called with their corresponding self values. This eliminates the need to do a type test and is a win in both code complexity and code speed.

Finding a way to put method lookup into its own namespace would make Lua a better language for engineering significant programs and a better language for novice users because more errors would be likely to be caught earlier.

Mark