lua-users home
lua-l archive

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

> > Would an explicit lambda keyword help?
> not sure. What yould be the semantics of this? A lambda defining a one-expression function? Because, if you go
> lambda(x) do something_with(x) end

Sorry for jumping in late and following the discussion closely, but what about
not allowing statements and having something like below?

lambda `(' [parlist] `)' explist

I think this would cover most of the needs for a lightweight syntax. Taking a
recent snippet from Mark Hamburg, for example:

stream:map(lambda(x) x * x)
      :filter(lambda(x) x % 2 == 0)
        total = total + x
        log:writef("%d %d", x, total)


Computers are useless. They can only give you answers.
                -- Pablo Picasso

Luis Carvalho (Kozure)
lua -e 'print(((""):gsub("(%u+%.)","")))'