lua-users home
lua-l archive

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


On Wed, Apr 9, 2014 at 9:25 PM, Sven Olsen <sven2718@gmail.com> wrote:
>> The expression: a, b, c in some_table    -- which can appear in any
>> expression
>
>
> Making this work would get tricky.  Table constructors also allow expression
> lists, so how should we interpret:
>     {  a, f(0), b in t } ?

item1, item2, item3, ... in some_table

^ this would essentially generate a vararg, and would hold to the same
rules of how varargs are transformed in an expression?  So because it
appears last in that construction the full vararg would "slide in" --
if it appeared first only the first item would be moved in, the others
would be shaved off -- a & f(0) would follow after b

> Peter's power patch allows 'in' to be used in any assignment.  That can be
> useful in certain situations; like setting up a new environment to contain a
> subset of _G:
>
>   local env={}
>   env.ipairs, env.pairs, env.print in _G

Hmm, I would want to write that as:

local env = { ipairs, pairs, print = ipairs, pairs, print in _G }

I wish multiple assignment were possible in table constructions :(  I
shall have to take a look at Peter's patch.

After thinking about this for a while I think it would be okay if
object literals were also allowed instead of only valid identfiers:

1, 2, 3 in { 'a', 'b', 'c' } --> return 'a', b', 'c'