[prev in list] [next in list] [prev in thread] [next in thread]
List: lua-l
Subject: Re: OP_SELF (was Re: Application of indexing to all types)
From: Mark Hamburg <mhamburg () adobe ! com>
Date: 2005-02-25 21:26:32
Message-ID: BE44D808.336F5%mhamburg () adobe ! com
[Download RAW message or body]
on 2/25/05 9:45 AM, Mark Hamburg at mhamburg@adobe.com wrote:
> If one redefines OP_SELF, then there probably need to be the following
> additional enhancements since the necessary information may not be readily
> available:
>
> lua_getmethod( lua_State* L ): A C API extension that takes the top two
> objects on the stack as obj and msg and does the appropriate method lookup.
>
> bindmethod( obj, msg ): A Lua function that takes an object and a message
> and returns a closure that sends msg to obj with any other parameters passed
> to the closure.
>
> hasmethod( obj, msg ): A Lua function that tests for the presence of a
> message -- i.e., it tells you whether it would be safe to send the message.
D'oh. I forgot callmethod( obj, msg, ... ). One could define bindmethod as:
function bindmethod( obj, msg )
return function( ... )
return callmethod( obj, msg, ... )
end
end
It might still be advantageous to write this in C where the stack
manipulation may be easier or more efficient, but it isn't strictly
required.
Mark
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic