lua-users home
lua-l archive

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


Jerome Vuarand <jerome.vuarand@gmail.com> writes:

> 2009/12/5 spir <denis.spir@free.fr>:
>> Can we consider simply wrapping the whole expression inside (...)?
>>   function (x,y,z) (x+y*z)
>>
>> This avoids the need for both '=' and an 'end' token.
>> (I guess "function(...)(...)..." is well a syntax error as of now?)
>
> This is not a syntax error. The following compiles well:
>     local f = function(...)(...)(...) end
> and can even be run (try f(print)).
>
> On the other hand, I don't think any valid expression or statement can
> start with a single square bracket. I'm not sure how to declare the
> parameter names, but here are some examples with an infix keyword
> ('with'):
>
> local f = [x + y with x, y]
> assert([x + y with x, y](3, 4) == 7)
> local t3 = map([x + y with x, y], t1, t2)
> foreach(t, [x + y with x, y])

x = { [y] = 4 }

is a valid initializer.  Your syntax uses brackets in a completely
different meaning than brackets are normally used in Lua.

I repeat: reusing existing syntax elements in inventive manners rather
than |...| is going to be even more, not less, confusing to casual
readers.

The problem with |...| was not that it needs better camouflage.

-- 
David Kastrup