lua-users home
lua-l archive

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


On Thu, 2004-11-04 at 10:38 -0800, Mark Hamburg wrote:
> For userdata, and userdata only, OP_SELF would be defined as looking for a
> __getmethod metatable entry before trying __index. (I chose the name
> __getmethod rather than __methcall since it doesn't actually do the call.)

Bad call. I assert that it is useful for pure lua too. In fact it's
almost 100% necessary for the class system I'm putting together. The
naming of it __getmethod is certainly better than my original __methcall
but I think I prefer __method to be consistent with __index

[snip rest]

the lua_getmethod() thing you suggested I think would be far better
served with something more like.

Given object at index obj

lua_pushstring(L, "foomethod");
lua_pushnumber(L, 12);
lua_pushstring(L, "otherarg");

lua_mcall(L, obj, 2, 1); /* call a method in obj given two arguments and
the method before them. return one value */

Then provide the obvious gamut of lua_pcall etc with the 'm' variant for
added happiness :-)

D.

-- 
Daniel Silverstone                         http://www.digital-scurf.org/
PGP mail accepted and encouraged.            Key Id: 2BC8 4016 2068 7895