lua-users home
lua-l archive

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


On Feb 5, 2010, at 9:21 AM, Pierre-Yves Gérardy wrote:

> Hi all,
> 
> I'm new to Lua but well aware of the conundrum regarding the short
> lambda syntax.
> 
> I couldn't refrain myself from proposing my own suggestion, though, so
> here it is:
> 
>   function(eat,food) return eat( food ) end
> 
> becomes
> 
>   (kick,ass): => kick( ass ) ::

If one can live without the ability to write multi-statement functions, then "( args ) => expr" is essentially the C# short lambda syntax. (I think. I've only written a little bit of C# and it's been a while.)

On the other hand, I think this becomes rather tricky to parse since one would have to parse relatively far to figure out whether a parenthesis was kicking off a parenthetical expression or whether it was kicking off a function definition. Hence, other alternatives like "\( args ) expr" or "| args | expr" seem preferable.

That said, your explicit end mark resolves the precedence issues that all of the above choices exhibit.

Mark