[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: RFE: table ctor syntax enhancement for many-to-one mappings
- From: HyperHacker <hyperhacker@...>
- Date: Mon, 22 Aug 2011 03:28:17 -0600
On Mon, Aug 22, 2011 at 03:16, steve donovan <steve.j.donovan@gmail.com> wrote:
> On Mon, Aug 22, 2011 at 11:08 AM, HyperHacker <hyperhacker@gmail.com> wrote:
>> I've often wished t[x,y,z] were legal when t has a __index or
>> __newindex, and would pass x,y,z as arguments to them.
>
> If it could be done efficiently, it would be a useful thing. (By
> 'efficient' here I mean 'at least does not make the usual case less
> efficient')
>
> steve d.
>
>
I'd imagine the compiler would only have to generate additional code
if the table index is multiple values or a function call that might
return multiple values (i.e. not wrapped in parentheses). That should
cover the majority of cases anyway...
There's a patch on the wiki that translates t[x,y,z] to t[x][y][z] as
well, but that's probably slower, since you'd have to return a table
with a metatable for the [y] and again for the [z]...
--
Sent from my toaster.