March 28 meeting notes

Brendan Eich brendan at mozilla.org
Thu Mar 29 12:26:37 PDT 2012


Andreas Rossberg wrote:
>
>     Dave did:
>
>     http://wiki.ecmascript.org/doku.php?id=strawman:return_to_label
>
>     It did not seem to be headed for consensus and inclusion in
>     harmony:proposals when we last discussed it.
>
>
> Interesting. But this is different from what I had in mind. It is more 
> like a generalisation of 'break', while I was thinking of something like:
>
>   function f(o) {
>     o.forEach(function g(x) {
>        if (...) return 0 from f;
>        let x2 = x.map(function h(y) {
>          if (...) return from g
>          return y*2  // returns from h
>        })
>        ...
>     })
>     return 27
>   }
>
> That is, just a way for referring to the specific function (or arrow 
> function, if we had a syntax for naming them) that the return is 
> supposed to be associated with.

Nice. This gives functions some of the oomph of block-lambdas (see 
https://gist.github.com/1677893 from @wavded [Marc Harter]). However:

* Requires function declarations, or seems to -- too restrictive (vs. 
arrows as block-lambda replacement in the gist above)?

* Waldemar's point about try/finally standing in the way of a forced 
return. Perhaps this is "you get what you ask for".

Still, very pretty syntax, nice contextual 'from' keyword linkage.

> (I suppose Dave's proposal can encode that, but it would result in 
> less natural and significantly more verbose code.)

(Yes, it's escape continuations for JS, so it can do more but you have 
to say more.)

/be


More information about the es-discuss mailing list