From: [email protected] [mailto:[email protected]] On 
Behalf Of Mark S. Miller
Sent: Friday, November 9, 2012 08:33

> Hi David, thanks for your thoughtful post. I've always used the two-arg form 
> of .then[1], but your post makes a strong case for more often using separate 
> one-arg .then and .fail calls.

We have found this to be more expressive as well. Especially in ES5 
environments, where we can use Q's alias of `catch` instead of `fail`:

p1.then(val => doStuff)
     .catch(err => console.error(err));

> I have been using "when" rather than "then". Because these are otherwise 
> compatible AFAICT with A+, for the sake of consensus I'm willing to change 
> this to "then" everywhere. But before I do, I'd like to make one last plea 
> for "when" and see how this community responds.

I think perhaps because of my background as someone who has only ever 
programmed for nontrivial amounts of time in curly-bracket languages (C, C++, 
C#, JavaScript), I really don't see "then" as part of an "if-then-else" chain. 
None of your examples seem confusing to me! I don't know though, as this is 
obviously very subjective.

However, I see a lot of value in "when" as a word still. "Then" makes sense 
when used as a method:

doThis().then(doThat).then(doAnotherThing)

But "when" makes sense when used as a function:

let this = doThis();
let that = when(this, doThat);
let anotherThing = when(that, doAnotherThing);

or even

let that = when(this).then(doThat);

where here `when()` is either making a value into a promise or assimilating an 
untrusted (or crappily-implemented) promise.

It also, to me, makes sense when used as a message, in the sense of 
promiseSend. This is a bit less important though I guess.


_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to