Bringing setTimeout to ECMAScript

liorean liorean at gmail.com
Fri Mar 18 09:41:59 PDT 2011


On 18 March 2011 17:25, Wes Garland <wes at page.ca> wrote:
> Right: the barrier to setTimeout functionality is that ECMAscript does not
> define a concurrency model.
>
> If we can define a concurrency model, then we can build setTimeout.
>
> Two things off the top of my head to consider:
>  - timer granularity
>  - forbidding eval-like syntax
>
> OTOH, if we have an event-loop system with conditionals, we might not need
> setTimeout because it would be trivial to build from primitives. But it
> might be a handy interface if ES starts to go toward the "batteries
> included" model.


As I understand it, this type of thing was kept out of the language
proper intentionally, because of its strong dependency on host
environment. Some host environments may require tight and overriding
control of any event handling system, and exactly which types of
events (such as timeouts) are suitable to an environment may vary. A
server side host might not want to have to deal with asynchronous
activity at all, for instance.

-- 
David "liorean" Andersson


More information about the es-discuss mailing list