[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lightweight syntax: a dissident view
- From: "Juris Kalnins" <juris@...>
- Date: Mon, 29 Nov 2010 09:27:32 +0200
On Fri, 26 Nov 2010 21:10:10 +0200, Mark Hamburg <mark@grubmah.com> wrote:
At the risk of having accusations of Perlishness flung around, there's
also the option of just optimizing the single-parameter,
single-expression case and introducing a token like $ which essentially
turns anything it touches into a function with spreading "contamination":
$ --> function( x ) return x end
$ + 1 --> function( x ) return x + 1 end
( $ + 1 ) * $ --> function( x ) return ( x + 1 ) * x end
$ - x --> function( y ) return y - x end
Too tricky. One must arbitrarily chose where to stop contamination in the
grammar. Consider:
? --> return some_proxy_obj[function( x ) return x end]
? --> return function( x ) return some_proxy_obj[x] end
? --> return function( x ) return math.sin(x) end, function return
math.cos(x) end
? --> return function( x ) return math.sin(x), math.cos(x) end
Note that ... token already stands for "arguments".
So if 'return' in expression context would define anonymous vararg
function,
greedily matching comma separated list of expressions
(this is the second time I try to push this idea, because it looks
very cute), then your examples could look like:
$ --> return (...)
$ + 1 --> return ... + 1
( $ + 1 ) * $ --> (return ( ... + 1 ) * ...)
$ - x --> return ... - x
- 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
- Re: Lightweight syntax: a dissident view, phlnc8
- Re: Lightweight syntax: a dissident view, Erik Lindroos
- Re: Lightweight syntax: a dissident view, phlnc8
- Re: Lightweight syntax: a dissident view, Mark Hamburg