slightlyoff / Promises

DOM Promises IDL/polyfill
Apache License 2.0
154 stars 28 forks source link

Futures-for-futures #13

Closed domenic closed 11 years ago

domenic commented 11 years ago

I feel like I tried to bring this up earlier, but it deserves its own issue.

Futures-for-futures are hazardous in the following manner (via @briancavalier, indirectly via MarkM, I believe):

let future = new Future(({ accept }) => accept(5));
let futureForFuture = new Future(({ accept }) => accept(future));

let identity = x => x;

// With ordinary futures, this is a composable identity transformation:
let a = future.then(identity);
// That is, `a` will be accepted with `5` as its value, just like `future`.

// But with futures for futures, identity is broken:
let b = futureForFuture.then(identity);
// That is, `b` will be accepted with `5` as its value, but
// `futureForFuture` of course has `future` as its value.

// This prevents `identity` from being used as a no-op in the general case.

Do you agree that this is a problem? If so, I am happy to discuss solutions, as we have been doing over in Promises/A+ land. If not, /shrug.

slightlyoff commented 11 years ago

I don't accept that this is a practical issue.