lua-users home
lua-l archive

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


Does Lua need a short lambda syntax? I like FP and lambda calculus as
much as the next guy, but if you want a minimalist functional language
what is wrong with Scheme?

On 2/5/10, Majic <majic.one@gmail.com> wrote:
> Sounds something like Haskell, tbh... I'm still learning how to do
> much of anything in that language, but I believe it's:
>
> functonname var1, var2 -> var1 var2
>
> (Since there are no parenthesis var2 is supplied to var1, called like
> a function?)
>
> Personally, I like how verbose Lua is...  makes things (at a glance to
> new programmers) pretty self-explanatory. :>
>
> On Fri, Feb 5, 2010 at 10:16 AM, Mark Hamburg <mark@grubmah.com> wrote:
>> 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
>>
>>
>