lua-users home
lua-l archive

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


>> Wouldn't a more Lua-like approach be to use a keyword "lambda" instead
>> of a symbol? I think my favourite syntax would be:
>> lambda x: x+1
>
> Yes, but the problem we're allegedly trying to solve is that many functional
> patterns are so bulky to express in Lua that nobody uses them. So the
> pendulum swings the opposite way, towards terseness, because under this
> hypothesis the lambda construct for procedure construction is so fundamental
> it needs short syntax, at least as short as table  construction.
>

Lua's function syntax is fine, the keywords are just a bit, well, verbose.

The problem can be addressed at the lexer/parser level, since so many special
characters are still unused.  For example.

'@' is a synonym for 'function'
'= is a synonym for 'return', as in the shell (unary '=')
'!' is a synonym for 'end'

Then

   @(x)=x+1!

Not my idea -- the trick comes from an early version of the language
Turing.

Dirk