lua-users home
lua-l archive

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


On Fri, Feb 17, 2012 at 21:36, Xavier Wang <weasley.wx@gmail.com> wrote:
> no need, you can throw a error when you see 'in' and list is not a namelist
>
> 在 2012-2-18 中午12:24,"HyperHacker" <hyperhacker@gmail.com>写道:
>
>> On Fri, Feb 17, 2012 at 16:38, Sven Olsen <sven2718@gmail.com> wrote:
>> >>
>> >> > So, what about the semantics become a exprlist?
>> >> > exprlist ::= expr { ',' expr } |
>> >> >                  namelist 'in' expr
>> >> >
>> >> > this allows some syntax:
>> >> > local a, b, c = d, e, f in t
>> >> > dump(a, b, c in t)
>> >> > local t = {a, b, c in t}
>> >
>> >
>> > That would be quite cute.  Of course, I'm not familiar enough with the
>> > grammar to know if it might cause other kinds of parser trouble :)
>> >
>> > If you could get it working, I'd certainly be a fan of such a patch.
>> >
>> > -Sven
>>
>> It seems troublesome to me:
>> local x, y, z = a, b, c in t
>> does that parse as: local x, y, z, = t.a, t.b, t.c
>> or as: local x, y, z = a, b, t.c ?
>> In the former case, there's no way to access anything *not* in t; in
>> the latter, it's not very useful. Not to mention, the parser has to
>> read ahead an arbitrary number of tokens to see where it's meant to
>> pull these names from.
>>
>> --
>> Sent from my toaster.
>>
>

But these are name lists; it's just not clear whether the names refer
to _ENV or some other table until you reach the end.

-- 
Sent from my toaster.