[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lightweight syntax: a dissident view
- From: phlnc8 <phlnc8@...>
- Date: Fri, 26 Nov 2010 12:54:17 -0500
How about
[ x : x > 3 ]
[ x, y : x+y, compute_something_else(x,y) ]
Syntax (reusing Lua syntax terms):
'[' parlist ':' explist ']'
This form would syntactic sugar for
function(parlist) return explist end
Rationale:
- keep it simple: no statement, no block, just an expression.(if
function is more complex, just use regular 'function ... end' syntax)
- a closing token which makes it easy to have multiple return values
- balanced openning/closing tokens, which makes it easy to see the
anonymous function boundaries within any reasonable text editor
- no keyword that may be unfamiliar to some (lambda)
- no '\' which may be hard to type on some keyboards, ... and which
may introduce some confusion with hex escape chars (eg. using a local
variable named 'n': the form \n(n*n) needs some escaping to be loaded
with loadstring...)
What do you think?
On Fri, Nov 26, 2010 at 1:09 AM, steve donovan:
>> How about simply this
>>
>> lambda(x) x == 2
>
> Fine, but then you started to make it complicated ;) If there are
> actual statements in an anonymous function, then the existing syntax
> is fine as it is.
>
> I read this as 'lambda' <arglist> <expr>, with the operator 'lambda'
> <arglist> having the highest precedence.
>
> Not sure in fact whether multiple return values should even be allowed
> in this case .... that is, how one would interpret this?
>
> lambda() (10,20)
>
> The syntax and semantics should be as simple as possible,and then
> there are less ugly edge cases.
- References:
- Re: Re: Re: Lightweight syntax: a dissident view, Gunnar Zötl
- Re: Re: Re: Lightweight syntax: a dissident view, Luis Carvalho
- Re: Re: Re: Lightweight syntax: a dissident view, Axel Kittenberger
- Re: Re: Re: Lightweight syntax: a dissident view, Pierre-Yves Gérardy
- Re: Re: Re: Lightweight syntax: a dissident view, Roberto Ierusalimschy
- Re: Re: Re: Lightweight syntax: a dissident view, Mateusz Czaplinski
- Re: Re: Re: Lightweight syntax: a dissident view, Axel Kittenberger
- Re: Lightweight syntax: a dissident view, Philippe Lhoste
- Re: Lightweight syntax: a dissident view, Pierre-Yves Gérardy
- Re: Lightweight syntax: a dissident view, Mark Hamburg
- Re: Lightweight syntax: a dissident view, Pierre-Yves Gérardy
- Re: Lightweight syntax: a dissident view, Pierre-Yves Gérardy
- Re: Lightweight syntax: a dissident view, Axel Kittenberger
- Re: Lightweight syntax: a dissident view, steve donovan