You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 26, 2019. It is now read-only.
Some people have brought up that introducing a third main type of completion is a big deal and that maybe it should be avoided.
I think we need to preserve the following requirements no matter the shape of the solution:
catch (e) { ... } does not catch cancelations
cancelations never reach the host environment's error handling mechanisms (HostReportErrors in the spec)
There are symmetrical constructs for catching/throwing cancelations as there are for throw completions (catch/throw)
One proposal that still meets all these requirements is as follows:
Introduce a special type of object, a "cancelation", which is branded in some way.
Cancelations are not caught by catch (e) { ... }
If a cancelation reaches the top level it is not sent to HostReportErrors.
We somehow introduce new guard syntax which can catch cancelations. General catch-clause pattern matching? catch cancel (e) { ... }?
To throw a cancelation you just construct it and throw it like any other exception, e.g. throw new Cancelation("..."). I'd even be in favor of introducing a global function named cancel so you can do throw cancel("..."), but people might object to introducing a new global with such a generic name. (We got away with it for fetch and close and open and others, though.)
I think this alternate proposal is not as good as the third state proposal for a couple weak reasons:
I think it is trying to impose a false parsimony of concepts. Cancelations and exceptions are actually very different things, and saying that cancelations are just a type of exceptions with several special rules surrounding them is conceptually messy and wrong, in my opinion.
The details of the catch guard syntax is very unclear. Catch guards could be their own very large proposal in their own right, and introducing such a dependency is not a good way to get cancelation working.
As such I plan to continue pursuing the third state approach. But I wanted to leave this as a record of my thoughts on the matter. If someone wants to take ownership of an alternate proposal I'd be willing to work with them.
Some people have brought up that introducing a third main type of completion is a big deal and that maybe it should be avoided.
I think we need to preserve the following requirements no matter the shape of the solution:
catch (e) { ... }does not catch cancelationsOne proposal that still meets all these requirements is as follows:
catch (e) { ... }catch cancel (e) { ... }?throw new Cancelation("..."). I'd even be in favor of introducing a global function namedcancelso you can dothrow cancel("..."), but people might object to introducing a new global with such a generic name. (We got away with it for fetch and close and open and others, though.)I think this alternate proposal is not as good as the third state proposal for a couple weak reasons:
As such I plan to continue pursuing the third state approach. But I wanted to leave this as a record of my thoughts on the matter. If someone wants to take ownership of an alternate proposal I'd be willing to work with them.