Bringing setTimeout to ECMAScript

Boris Zbarsky bzbarsky at MIT.EDU
Sun Mar 20 10:23:32 PDT 2011

On 3/20/11 1:19 PM, David Bruant wrote:
> I agree that some properties of a scheduling policy can be tested (like
> you can test that times moves forward with two sequential calls to
> or testing statistical properties of Math.rand()) but there
> is something in the time that code uses to execute that is inherently
> non-determinist (the dead code elimination optimization is actually an
> excellent proof of this). This cannot be avoided in my opinion, making
> scheduling policy non-testable, not verifyable and hence non-relyable.

It should be possible to statistically verify (which is the only way you 
can verify anything via a test suite, by the way) the following 
assertion:  "Given two calls |setTimeout(f, n)| and |setTimeout(g, n)| 
using the same value of |n|, if the |setTimeout(f, n)| happens before 
the |setTimeout(g, n)| then f will be called before g."

Last I checked, the web depends on that behavior to some extent. 
Implementing it is not particularly burdensome.


More information about the es-discuss mailing list