Expression closures - use-cases for shortcut lambda syntax (blocks)

Vassily Gavrilyak gavrilyak at gmail.com
Sun Mar 18 09:30:45 PDT 2007


On 3/18/07, Brendan Eich <brendan at mozilla.org> wrote:
> We've been writing int -> int when discussing the type system,
> because it's too painful (especially on a whiteboard) to write
> function(int):int.
Yes, I agree. I have the same issue when reading the specs.
There is also one more issue. When ES4 will get IDE's with tooltips
for methods declarations,  it would be good to have nice way to show
those tooltips.

> When Dave suggested function (formals) expression, Jeff Dyer wanted
> something like => after the (formals) -- he suggested = at the time.
>
> I think this clinches it. We have been circling around the design
> point of (formals) => assign-expr (you're right about not wanting
> comma to bind more tightly than =>) for a while. Using -> when C#
> uses => would just be gratuitous.
>
> I would require parentheses around the formals, even when there is
> only one.
Probably I would too. That will be confusion for C# people. Not a big issue.
> In a class, I'm not so keen on name(formals) => expression defining a
> method, given the lack of a binding form elsewhere.
Me too, better to write
function name(){
}
because it's exactly FUNCTION declaration. Shortcuts can be
disallowed  here at all.
By language or by company policy.

So, does such syntax have a chance to be in ES?

> /be
>
> On Mar 18, 2007, at 8:47 AM, Vassily Gavrilyak wrote:
>
> > Correction :-)
> >> The only place where it doesn't work is type declaration.
> > should be read as:
> > It also works nicely with type declarations
> >
> > So something like this
> > function map(mapper: (function (_:*, _:uint, _:Object):*),
> > thisObj:Object):Array
> > will become this
> > function map(mapper: (_:*, _:uint, _:Object) => *,
> > thisObj:Object):Array
> >
> > Regards,
> > Vassily
> > _______________________________________________
> > Es4-discuss mailing list
> > Es4-discuss at mozilla.org
> > https://mail.mozilla.org/listinfo/es4-discuss
>
>



More information about the Es4-discuss mailing list