韩冬 (2015-10-03T12:04:24.000Z)
forbes at lindesay.co.uk (2015-10-04T11:06:10.037Z)
I want to know more about the implementation about Promise after two day of research, there’re two different ways of implementing a chain style control structure, one is based on an internal state machine, which save the callback for a moment, and resolve them after async function finish, the other one is based on continuation, every node on the chain are a new continuation contain the computation on the chain, some kind of porting the ConT monad from haskell to javascript, i’d like to compare them and get to know why the state-machine based solution eventually won? Here is my summary: Pros for state machine based solutions: * Auto memorization. * Easy sementics. Cons for state machine based solutions: * Bad reusability. * Larger overhead. Pros for continuation based solutions: * Good reusability, since continuation are just functions. * Lower overhead. Cons for continuation based solutions: * Complex sementics. * No memorization(can be done by other ways). Do you agree with me on this summary? and suppose in future javascript will get multicore support, will the state-machine based solution subject to race condition? Thanks again for giving me lots of detail about the history, now i need more : )