[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Short function definition syntax; thoughts on Lua (was Re: [ANN] GSL Shell new beta release...)
- From: steve donovan <steve.j.donovan@...>
- Date: Thu, 10 Dec 2009 07:14:41 +0200
On Wed, Dec 9, 2009 at 7:03 PM, Gregg Reynolds <dev@mobileink.com> wrote:
>
> sizes = names.map {_.gsub("%A", "").lower}
It's tempting (Scala has a similar notation) but alas, underscore is
just an ordinary variable, which is comnonly used when you want to
throw away a value. And if you consider tonumber(_) you see that the
parser has to do a lot of work to mark these expressions as actually
being functions.
Although it does make a nice notation for 'string lambdas', if you
don't mind quoting your short functions.
map '_:gsub("%A","):lower()'
In Penlight we used placeholder variables, so functions like map would
take expressions like _1+1 and _1*_2, which was inspired by the C++
Boost libraries.
steve d.