March 28 meeting notes

Andreas Rossberg rossberg at google.com
Thu Mar 29 12:16:59 PDT 2012


On 29 March 2012 20:35, Brendan Eich <brendan at mozilla.org> wrote:

> Andreas Rossberg wrote:
>
>  On 29 March 2012 16:11, Brendan Eich <brendan at mozilla.org <mailto:
>> brendan at mozilla.org>> wrote:
>>
>>    Yesterday, Luke made a stronger point: TCP 'return' means async
>>    callbacks (e.g. promise when functions) must be written ML-style,
>>    with return value in tail position. Callbacks can be lengthy, so
>>    writing and if-else nest with a variable holding the r.v. to
>>    achieve this is awkward and users will prefer early returns (so
>>    the calllback's spine is the normal execution path). But TCP will
>>    make these wrong-return bugs.
>>
>>
>> I actually think this is a less severe problem. Ignoring the issue of
>> potential confusion for users (which is real), the main thing lacking there
>> in terms of expressiveness is some labelled variant of 'return', analogous
>> to break and continue. If we were so inclined, I'm sure we could come up
>> with something usable on that front.
>>
>
> Dave did:
>
> http://wiki.ecmascript.org/**doku.php?id=strawman:return_**to_label<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.

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

/Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120329/9c24b0dc/attachment.html>


More information about the es-discuss mailing list