|
Mark Hamburg wrote:
Looking at the VM and the compiler, I'm guessing that the colon always goes through OP_SELF and essentially nothing else does? Is this correct?
Yes, I think so.
If so, could one teach OP_SELF to look for another metatable entry -- e.g., __self -- in addition to __index? That way, one could put the "I only want to be used in a colon-operator call" C functions in the __self table and be assured that they were being used with the right datatype? Or is there more that would need to be done? (I know that TM_SELF would probably need the same optimizations as TM_INDEX.) Is this a reasonable proposal?
Yes. Hi Mark,I've experimented with this idea too. There is a patch at the bottom of my wiki page:
http://lua-users.org/files/wiki_insecure/users/pshook/lua-5.0-self.patch - Peter