[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Short function definition syntax; thoughts on Lua
- From: David Kastrup <dak@...>
- Date: Sun, 06 Dec 2009 09:45:34 +0100
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
- References:
- [ANN] GSL Shell new beta release with anti-gran graphics module, Francesco Abbate
- Re: [ANN] GSL Shell new beta release with anti-gran graphics module, David Kastrup
- Re: [ANN] GSL Shell new beta release with anti-gran graphics module, Norman Ramsey
- Re: [ANN] GSL Shell new beta release with anti-gran graphics module, David Kastrup
- Re: [ANN] GSL Shell new beta release with anti-gran graphics module, Norman Ramsey
- Short function definition syntax; thoughts on Lua (was Re: [ANN] GSL Shell new beta release...), Doug Rogers
- Re: Short function definition syntax; thoughts on Lua (was Re: [ANN] GSL Shell new beta release...), steve donovan
- Re: Short function definition syntax; thoughts on Lua (was Re: [ANN] GSL Shell new beta release...), Luiz Henrique de Figueiredo
- Re: Short function definition syntax; thoughts on Lua (was Re: [ANN] GSL Shell new beta release...), spir
- Re: Short function definition syntax; thoughts on Lua (was Re: [ANN] GSL Shell new beta release...), Jerome Vuarand