22 maj 2016 kl. 16:40 skrev Marcus Agehall (nu med K-märkt fastighet och ny elcentral) @ Pike (-) developers forum <10353@lyskom.lysator.liu.se>:

I have spent some time looking at the new stuff in Concurrent.pmod
that Grubba has added to 8.1. Mostly it is code relating to the
concept of Promises and Futures which are very popular amongst
JavaScript people these days.

[…]

A bigger problem imho is the difference in how promises are actually
resolved. In JavaScript, the return value of then() is always a *new*
promise which then allows for chaining. In Pike, we return the same
promise object. This means that code like

my_promise->on_success(foo)->on_success(bar)

in Pike would result only in a call to bar() once my_promise is
resolved whereas in JavaScript, foo() would be called and it's return
value would be the input to bar in a new promise.

I agree that a new promise (or future rather) should be returned. You can blame me since on_success/on_failure were void functions originally so I added the return stuff so you could chain an on_failure onto an on_success. But you are correct, that should probably be a new future, and if on_success/on_failure returns a future that’s the one to be resolved in the next chained on_success/on_failure.

Regards
-----------------------------
Pontus Östlund
Developer • Roxen AB
+46 70-662 81 69

www.roxen.com | twitter.com/roxen