Allen's lambda syntax proposal

Peter Michaux petermichaux at gmail.com
Sun Nov 30 00:28:01 PST 2008


On Sat, Nov 29, 2008 at 11:53 PM, Brendan Eich <brendan at mozilla.com> wrote:
> On Nov 29, 2008, at 11:33 PM, Peter Michaux wrote:
>
>> This would allow writing
>>
>>  var foo = {|a, b, c| ...};
>>
>> which could be written even shorter as
>>
>>  var foo(a, b, c) {...};
>
> Why ever would you want to use 'var' there? Could foo be reassigned to
> denote 42, or "hello"?

Yes it could be reassigned.

It is analogous to

  (define (foo a b c) ...)

Could also write

var foo(a, b, c) {...}
let foo(a, b, c) {...}
const foo(a, b, c) {...}


>> The later is more consistent with the following which would also be
>> necessary at times.
>>
>>  lambda(a, b, c) {...}
>
> Necessary for what use-case?

I believe the same ones as for {|a, b, c| ...}. For example, if one
wants to pass an anonymous lambda to another lambda.

----

If this is a more serious thread about syntax, I think all the
callable things should have semetrical declaration syntax

lambda(a, b, c) {...}
function(a, b, c) {...}
class(a, b, c) {...}

Especially the syntax for lambda and function declarations seem as
though they should be symmetrical because they will be called the same
way: "foo()". This also makes me thing that class's should be called
the same way. That is, the "new" should be optional just like it is
for Array constructor, for example.

There is beauty in symmetry and nature has shown over and over again
that symmetry is a sign of good fitness. I think this is widely known
to be related to Lisp and its strengths. One interesting thing about
Lisp is that s-expressions were not the intended end syntax.
M-expressions were going to be more like languages which have
"syntax". Once the power enabled by the symmetry of s-expressions was
subsequently discovered it was so persuasive that they stuck.

By adding more syntax ES could be digging a deeper hole which favors
syntax over other semantically useful ideas.

Peter


More information about the Es-discuss mailing list