[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Multiple indexing (was: 'in' keyword today)
- From: Tom N Harris <telliamed@...>
- Date: Thu, 10 Apr 2014 23:09:37 -0400
On Thursday, April 10, 2014 01:56:36 PM Thomas Jericke wrote:
> I have a problem with that fallback. It doesn't give back the same
> number of results as the usual metamethod.
> You would have the same problems as if you were allowed to return
> multiple results from the normal __index metamethod.
So if multiple indexing were combined with multiple get/set on a table index
then we could end up with:
sometable[somekey(...)] = anothertable[anotherkey(...)]
And that would be compiled into something like:
a = gettable(_ENV, "sometable")
b = gettable(_ENV, "somekey")
c... = b(...)
d = gettable(_ENV, "anothertable")
e = gettable(_ENV, "anotherkey")
f... = e(...)
g... = gettable(d, f...)
settable(a, c..., g...)
That last one is a problem. What is the signature of an opcode that takes two
variable lists of values?
I don't like either of these proposals, or the often mentioned tuple type. I
even used to be an advocate of tuples. But today's discussion has made me
doubt if it can be implemented efficiently. Too many variadic values will run
roughshod over register allocation.
--
tom <telliamed@whoopdedo.org>