[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Multi-indexed tables
- From: Philippe Verdy <verdy_p@...>
- Date: Sun, 9 Dec 2018 23:15:42 +0100
op codes are not an issue at all here; there's still a sequence of opcodes possible to compute RK(C) in a register mapping the expected key from the pair.
Even the code "t" would also generate a sequence (GETTABLE;SETTABLE) or (GETTABLE,GETTABLE) and not a single opcode...
On Sun, 9 Dec 2018 at 18:12, Dirk Laurie <email@example.com> wrote:
> 1. Is there any syntactic reason why one can't patch Lua so that
> t[1,2] won't raise a compilation error, but instead invoke
> __index(t,1,2) or __newindex(t,1,2,v)?
I think there are issues with the way the table op codes work - and
the number of registers they allow.
GETTABLE A B C R(A) := R(B)[RK(C)]
SETTABLE A B C R(A)[RK(B)] := RK(C)
The opcode doesn't have room for additional registers.
Lua's parsing also assumes that there is a single register for the key.