lua-users home
lua-l archive

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


On Fri, Dec 4, 2009 at 4:12 AM, Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:
> But there is a middle way; say there was a new keyword 'lambda', so
> that we can say lambda(arglist) expr, then a token filter could easily
> transform |x| into lambda(x).

Why 'lambda' when 'function' exists and works just as well?

Sorry I'm late to the party, but if the goal is to have an ultra-concise syntax for short one-off nameless functions, why bother naming arguments?  If 'lambda' (or 'function' or whatever) serves in combination with named parameters to name a function, wouldn't it be possible dispense with even that by just nominating a distinguished symbol to reference actual arguments?  E.g. underscore:

sizes = names.map {_.gsub("%A", "").lower}

Inspired obviously by pattern matching syntax.  I have no idea if this would be doable in Lua but as a syntax it seems to fit the bill for short functions - easy to type and read.  Multiple args could be handled by indexing, _[1], etc.

-gregg