lua-users home
lua-l archive

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


How would the compiler know what obj is? Sintactic sugars are dealt with at compile time. Otherwise Lua compiler has no information onto what obj might be at run time.

AB 

-----Original Message-----
From: Mark Hamburg [mailto:mhamburg@adobe.com]
Sent: Tuesday, September 21, 2004 10:34 PM
To: Lua list
Subject: Functional objects


PiL finishes the chapter on object-oriented programming with the rather
Scheme-like approach of implementing objects as function closures. Would it
make sense to define obj:msg( ... ) as meaning obj( "msg", ... ) if obj were
a function? This has the downside of meaning that the syntax is no longer
simply sugar, but it had already ceased to be treated as such in the
implementation.

It might actually be nicer to have it mean obj( obj, "msg", ... ) but that
may confuse parameter counts in the implementation since the case where obj
isn't a function doesn't pass the message to the method.

Mark