Brendan Eich brendan at mozilla.com
Tue Apr 23 18:41:10 PDT 2013

Tab Atkins Jr. wrote:
> On Sat, Apr 20, 2013 at 6:17 AM, Brendan Eich<brendan at mozilla.com>  wrote:
>> Tab Atkins Jr. wrote:
>>> It would be so nice if JS had multiple return values, so we could let
>>> cancellable future-returning APIs just return a naked resolver as
>>> their second value,
>> Hello, destructuring:
>> let{  proxy, revoke}  = Proxy.revocable(target, handler);
>> from http://wiki.ecmascript.org/doku.php?id=strawman:revokable_proxies. Or
>> use an array pattern if you prefer.
>> JIT'ing VMs can optimize these pretty easily to avoid object allocation.
> Yeah, that's fine when you're explicitly invoking something that needs
> to return two objects.

You didn't grok what I wrote. The object is erased, and the value(s) are 
returned to the caller depending on the pattern it uses.

> It's less fine when you have something like a hypothetical getJSON()
> (future-returning XHR sugar), which can reasonably just return a
> future, but which we also want to make cancellable.  Burdening *every*
> call site

No, you can use a smaller pattern, e.g.

let { future } = getJSON();

instead of

let { future, cancel } = getJSON();

>   with the need to pull out the future from the returned
> object

No, see above.

>   isn't great.



More information about the es-discuss mailing list