[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lightweight function syntax (again) Re: [ANN] Lua 5.2.0 (alpha-rc2) now available
- From: Scott Vokes <vokes.s@...>
- Date: Mon, 22 Nov 2010 14:27:06 -0500
On Mon, Nov 22, 2010 at 4:32 AM, Axel Kittenberger <axkibe@gmail.com> wrote:
> @(=> _1 + _2, _1 * _2)
> is short for
> function(a,b) return a+b, a*b end
In K / Q, if variable names are not given, it defaults to x, y, and
z (in the same sense you say _1, _2, _3). That seems like a good idea
to me, at least for rather short anonymous functions (e.g. "{x*x+y}"
).
The bigger issue is that languages whose code typically has a lot
of anonymous functions (Lisp, ML, Haskell, etc.) are
/expression/-oriented rather than /statement/-oriented, making the
"return" implicit. fun(a,b) a+b, a*b end" wouldn't be too bad, though
it's probably not worth adding another reserved word. "@{x+y, x*y}",
perhaps?
Scott