Allen's lambda syntax proposal

Maciej Stachowiak mjs at apple.com
Mon Dec 1 17:48:51 PST 2008


On Dec 1, 2008, at 5:37 PM, Allen Wirfs-Brock wrote:

>> -----Original Message-----
>> From: es-discuss-bounces at mozilla.org [mailto:es-discuss-
>> bounces at mozilla.org] On Behalf Of Douglas Crockford
> ...
>> because you can think of the \ as being an abbreviation of function.
>>
>>    \ name(a,b,c) {}
>>
>> Just don't start your function name with u.
>>
>
> Exactly, that's why I didn't mention this possibility.  I don't  
> think it would be acceptable to have that \u ambiguity.

I think requiring a space after the \ if a name is provided would  
remove the potential ambiguity.

> Smalltalk does not have a way (other than variable assignment) to  
> name closures for recursive reference and it rarely has proven to be  
> a problem.  If you really want to pass a recursive lambda to a  
> function g you could define it using a const:
>        const  fact = {|n|  (n<=1) ? 1 : fact(n-1)* n};
>      g(fact)
> or more perversely:
>        g({||const  fact = {|n|  (n<=1) ? 1 : fact(n-1)* n}; fact}() );
>
> (the second statement of the outer lambda wouldn't be needed if  
> const evaluates to the value of its initialization expression)

g(\ fact(n) { (n<=1) ? 1 : fact(n-1) * n });

That seems sweeter.

  - Maciej



More information about the Es-discuss mailing list