[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: __methcall
- From: Daniel Silverstone <dsilvers@...>
- Date: Fri, 05 Nov 2004 10:44:06 +0000
On Thu, 2004-11-04 at 17:34 -0800, Mark Hamburg wrote:
> I think your patch actually does:
> table first
> __methcall next
> __index last
I must apologise; you're quite right; I was misreading the semantics of
the last line of my luaV_methindex. It is of course
table[method] first
then if neither metatable.__methcall or metatable.__index exists; return
nil
then try to call (metatable.__methcall or metatable.__index)
then try to index as a table (metatable.__methcall or metatable.__index)
blergh; you can tell I'm tired.
> You would want the table to come before __index anyway if you wanted to
> preserve Lua's semantics when not using __methcall (or __methindex or
> whatever).
Yeah; but with a suitable __index,__setindex and a protected metatable
you cover your backs wrt. putting attributes into the table which could
cause issues. (E.g. by actually putting them into a proxy table)
Then again; perhaps __methcall should trump the contents of the table
after all? *stares at lvm.c for a moment*
Aha; that's where my confusion arose.
I was looking at (in isolation from each other) my patch; and the lvm.c
from lua 5.1 without trying to apply the patch to it. It wouldn't apply
due to massive changes which will force me to forward-port the patch
When I port the patch to lua 5.1, I imagine that since I'll have to
change the integration into the main vm loop ( OP_SELF has changed
dramatically) I'll probably make the ordering as I described. I.E.
__methcall, then __index, then the table itself. I feel that's the most
useful ordering as I don't like the idea of individual instance objects
overriding methods by setting internal attributes.
D.
--
Daniel Silverstone http://www.digital-scurf.org/
PGP mail accepted and encouraged. Key Id: 2BC8 4016 2068 7895