Bringing setTimeout to ECMAScript

John J. Barton johnjbarton at
Sun Mar 20 12:24:09 PDT 2011

On 3/20/2011 12:03 PM, Kyle Simpson wrote:
> ...
>> Multiple repeated calls to |setTimeout(f,0)| are bugs
> I don't agree with that assertion at all. Two different functions 
> might "queue up" two different snippets to happen "as soon as 
> possible, later", each of them using their own setTimeout(..., 0).
But I didn't say two different snippets. I said Multiple repeat calls to 
the same snippet.

>> and setInterval of zero would be a bug.
> setInterval(...,0) may be silly, but that doesn't mean it's a bug. It 
> means "make this happen as fast as possible", just like above where 
> setTimeout(...,0)  means "make this happen as soon as possible".
Looping as fast as possible is likely to be a bug. It's not similar to 
queuing events.
> The "swamping" would occur if setInterval(f,0) was actually going to 
> spin in sub-millisecond speeds. It could also occur if you fake 
> setInterval with:
> function f() {
>   // ...
>   setTimeout(f,0);
> }
> f();
Yes, like I said, multiple repeat calls to the same snippet.
> But in either of those cases, I don't see why there'd be any reason 
> for "clamping" at anything higher than 1ms (being the smallest unit of 
> time I can address with the API anyway)?
I can't see any reason to lump event queuing with looping when its 
looping that causes the issues.


More information about the es-discuss mailing list