W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2013

Re: Resolving Futures w/multiple values

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 23 Apr 2013 12:04:23 -0700
Message-ID: <CAAWBYDD6WQazQs_6Pg4iQwuGWKRGDAw1diWB=GBJeEsKhk86cg@mail.gmail.com>
To: Domenic Denicola <domenic@domenicdenicola.com>
Cc: Dave Longley <dlongley@digitalbazaar.com>, "www-dom@w3.org" <www-dom@w3.org>, Anne van Kestern <annevk@annevk.nl>, "slightlyoff@chromium.org" <slightlyoff@chromium.org>
On Tue, Apr 23, 2013 at 11:20 AM, Domenic Denicola
<domenic@domenicdenicola.com> wrote:
> Just as yoy can't return (or throw) multiple values from a function, so you
> can't fulfill (or reject) a promise with multiple values. Promises model
> asynchronous return/throw and the associated call stack, so multiple
> fulfillment values would be nonsensical.
> You may find
> http://domenic.me/2012/10/14/youre-missing-the-point-of-promises/ helpful?

Yes, as Dave said, you can model asynchronous return/throw without
having to be identical.  The relevant part of that modelling has no
relation to whether or not you can "return multiple values".

JS will likely never grow multiple return values, but it did, it has
as example several older languages, like Common Lisp.  The behavior
proposed in the OP is similar to Lisp's multiple values behavior,
where a naive call site only receives the first returned value and
drops the rest on the floor, while clueful call sites can receive all
of them.  This makes multi-returns broadly useful as a *side-channel*,
returning the "main value" as the first return value and secondary
information which is sometimes useful as additional return values.
For example, CL's FLOOR function returns the floored value first, and
the remainder second.

Received on Tuesday, 23 April 2013 19:05:10 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:20 UTC