lua-users home
lua-l archive

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


On Fri, Nov 26, 2010 at 1:02 PM, Erik Lindroos <gliptic@gmail.com> wrote:
> On Fri, Nov 26, 2010 at 6:54 PM, phlnc8 <phlnc8@gmail.com> wrote:
>>
>> How about
>>   [ x : x > 3 ]
>>   [ x, y : x+y, compute_something_else(x,y) ]
>>
>> Syntax (reusing Lua syntax terms):
>>   '['  parlist ':'  explist ']'
>
> It's hard to parse. For example:
> { [ x : x > 3 ] = 0 }
> The meaning of "[ x : x > 3 ]" cannot be determined until the '='. It needs
> arbitrarily large lookahead.

You're right! ':' cannot be used to separate arglist and explist ...
It should be replaced with, eg. '|':

   [ x | x > 3 ]
   [ x, y | x+y, compute_something_else(x,y) ]

Syntax (reusing Lua syntax terms):
  '['  parlist '|'  explist ']'


Phil