lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Wed, Dec 9, 2009 at 7:03 PM, Gregg Reynolds <> wrote:
> sizes = {_.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.