A way of explicitly reporting exceptions

Allen Wirfs-Brock allen at wirfs-brock.com
Mon Jun 23 14:16:45 PDT 2014

It seems to me that the best way to do this in ES6 would be to run the call backs as individual Jobs (what until recently we were calling ES Tasks, http://people.mozilla.org/~jorendorff/es6-draft.html#sec-tasks-and-task-queues ).  The mechanisms are already in the ES6 spec. so that any any unhanded exceptions that occur in a Job are handled in the common implementation defined manner.

What would have to be defined would be a new ES API for adding the invocation of a ES function as a pending job in a job queue.  Maybe something like:

Function.prototype.callAsJob = function(...args) {
    $$EnqueueJob("UserJobs", ScriptEvaluationJob, args);  //handwave for calling ES internal abstraction operation

then notifyListners could just be:

 for (listener of listeners) {

and all the event handlers would be enqueue before any of them actually ran, which I believe is closer to what we want in terms of the ES concurrency model. 

Of course, an ES level Jobs API could include other embellishments such as explicitly setting an unhandled exception handler for a Job, or associating completion of a Job with a Promise.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140623/1a6449ea/attachment.html>

More information about the es-discuss mailing list