"delay" keyword

Axel Rauschmayer axel at rauschma.de
Wed Jul 4 10:53:10 PDT 2012


Relevant: Why coroutines won't work on the web
http://calculist.org/blog/2011/12/14/why-coroutines-wont-work-on-the-web/

Explains why this idea clashes with the run-to-completion semantics of JavaScript and why generators are normally good enough.

On Jul 4, 2012, at 18:19 , Patrik Stutz wrote:

> Hi guys!
> 
> Today, a really cool idea for a new keyword in JavaScript came to my mind. It's called 'delay'.
> 
> What does the delay keyword ?
> 
> The delay keyword does nothing more than stop the execution of the current stack and immediately continues to the next task in the queue. But that's not all! Instead of discarding the stack, it adds it to the end of the queue. After all tasks before it are done, the stack continues to execute.
> 
> What is it good for?
> 
> delay could help make blocking code non-blocking while it still looks like synchronous code. A short example:
> 
> setTimeout(function(){
> 
>     console.log("two");
> 
> },0);
> 
> console.log("one");
> 
> delay; //since there is currently another task in the queue, do this task first before continuing
> 
> console.log("three");
> 
> 
> //Outputs: one, two, three
> 
> This simple keyword would allow us to create a synchronous-looking code wich is asynchronous behind the scenes. Using node.js modules, for example, would no longer be impossible to use in the browser without trickery.
> 
> There would be so many possibilites with such a keyword!
> 
> What do YOU JAVASCRIPT DEVELOPERS think about it? What do you think can I do to bring this into the new ECMAscript Specification?
> 
> Please disuss as much as you want! :)
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-- 
Dr. Axel Rauschmayer
axel at rauschma.de
twitter.com/rauschma

Home: rauschma.de
Blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120704/2e94f61d/attachment.html>


More information about the es-discuss mailing list