Block lambda is cool, its syntax isn't

Rick Waldron waldron.rick at gmail.com
Thu Jan 12 19:12:00 PST 2012


This one is from https://github.com/ecto/duino/blob/master/lib/board.js and
has more "real world" uses

https://gist.github.com/d2c8fcbab5a3da4c4dae

Rick


On Thu, Jan 12, 2012 at 9:55 PM, Rick Waldron <waldron.rick at gmail.com>wrote:

> From the perspective of someone who writes JS every day, the parens look
> and feel "right".
>
> Dave, you asked for some example code, this is actually from task.js:
>
> https://gist.github.com/e4e0e349f9cf35ad3370
>
>
>
>
>
> On Thu, Jan 12, 2012 at 9:09 PM, David Herman <dherman at mozilla.com> wrote:
>
>> On Jan 12, 2012, at 2:23 PM, François REMY wrote:
>>
>> > If not (as it seems to me), it means that a block lambda will not be
>> used as a statement by itself. If it's the case, it should defined as an
>> Expression only, where there's no anonymous block to conflict the syntax.
>> That solution has been chosen for object notation in the past. That way,
>> >
>> >   function() {
>> >       {
>> >           (a, b)
>> >           a.add(b)
>> >       }
>> >   }
>> >
>> > would still be an anonymous block where
>> >
>> >   function() {
>> >       asyncAction(..., { (a, b) a.add(b); } }
>> >   }
>> >
>> > would be a block lambda as an argument of an async function. No
>> semantic change for an identical syntax, in regards to strict ES5.
>>
>> So simple, and so brilliant. I love it!
>>
>> I must say, the parens look much prettier to me, and they're of course
>> more consistent with JS precedent.
>>
>> It does help to write a reasonable chunk of code to compare syntaxes for
>> uses of a feature "in the wild." Does some enterprising es-discusser wanna
>> take a big JS program with a bunch of little anonymous functions, swap them
>> out with block lambdas, and make two gists with the two different syntaxes?
>> That'd be super helpful.
>>
>> > And since I still continue to hope we'll ditch the unprefixed anonymous
>> block in some future revision of ES, that very small edge case could vanish
>> at the same time.
>>
>> I don't understand what you're referring to here -- what do you mean by
>> "unprefixed anonymous block?"
>>
>> > Does it seems possible/acceptable?
>>
>> Lovely.
>>
>> Dave
>>
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120112/652963f3/attachment.html>


More information about the es-discuss mailing list