You can disagree with anything if you're allowed to change the terms of the
discussion. :)
Brendan said JS is run-to-completion, which means that if you call a function
and control returns to you, no intervening threads of control have executed in
the meantime. But then you changed his example to this:
> //#1
> assert_invariants();
> function callBack () {
> assert_invariants(); // perhaps yes, perhaps no. There's no guarantee.
> };
> setTimeout(callBack, 1e3);
> return;
Now matter how you line up the whitespace, the semantics of a function does not
guarantee that the function will be called right now. When a programmer
explicitly puts something in a function (the function callBack here), they are
saying "here is some code that can be run at any arbitrary time." They are
expressing that *explicitly*. Whereas in a semantics with
fibers/coroutines/call/cc:
> //#2
> assert_invariants();
> f(); //might suspend execution
> assert_invariants(); // perhaps yes, perhaps no. There's no guarantee either.
> return;
the mere *calling* of any function is *implicitly* giving permission to suspend
the *entire continuation* (of the current event queue turn) and continue it at
any point later on, after any other threads of control may have executed.
If you want to claim these two things are equivalent, I feel pretty confident
predicting this conversation will quickly descend into the Turing tarpit...
Dave
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss