|
I wrote a patch on 5.1.something a while ago to support :[ _expression_ ] as a way to invoke OP_SELF. As I recall, I had to patch both the parser (obviously) and OP_SELF though both changes were minor. It definitely helps syntactically for cases where you want to do things like register callbacks to invoke — e.g., a weak table of object to selector mappings to be used for notification. It also allows one to have private methods by using hidden tables as keys. I haven't kept my patch around because I have been trying to stick closer to stock Lua more of the time, but if I could make one syntactic change in Lua it probably would be this. (That probably gets followed with wanting obj:method and obj:[ _expression_ ] when used outside of a call context to be shorthand for creating an appropriate closure object, but that's a much more complicated patch and there are interesting questions about whether it should do the method lookup immediately or at call time.)
|