non-self referencial cyclical promises?
Mark S. Miller
erights at google.com
Wed Feb 24 20:16:44 UTC 2016
On Wed, Feb 24, 2016 at 11:54 AM, Bergi <a.d.bergi at web.de> wrote:
> Bradley Meck wrote:
>> I was doing some recursive data structure work and ended up with a
>> promise that did not use a direct self reference. It can be reduced down
>> var af, a = new Promise(f=>af=f);
>> var bf, b = new Promise(f=>bf=f);
>> af(b);bf(a); // the problem
>> a.then(_=>_) // some env/libs need this to start checking status
>> According to
>> it looks like this should cause a recursive and infinite set of
> I fear that's what the standard says, yes. The ES6 spec does too many (and
> in some cases, unreasonably many) `then` calls on promises anyway to be
> followed by an efficient promise implementation.
> [Promises/A+](https://promisesaplus.com/) in contrast says
> | Implementations are encouraged, but not required, to detect such
> | recursion and reject promise with an informative TypeError as the
> | reason.
I think the standard *should* require a deterministic error. E <
Q, and my own Q-like system <
do. Within an engine, this technique should be straightforward to implement
without slowing down the non-cyclic case.
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss