One-shot Delimited Continuations with Effect Handlers

Sebastian Markbåge sebastian at calyptus.eu
Wed Mar 16 01:05:54 UTC 2016


> Perhaps if there was a way to wrap any arbitrary expression with a
> generator that captured any yielded values and allowed resumption by
> calling .next(), then you could accomplish this without inventing new
> try-catch syntax?
>

Yea, except you need to be able to nest them inside each other as well.

If a generator captured any yielded values, then it would be yielded at the
inner most caller.

You could handle this the way JavaScript does exception handling by
"rethrowing" errors it didn't handle. I.e. if you see a yield that you
don't recognize you would re-yield it.

In my use case I can have many nested handlers and I want to handle a
particular type at the top of the stack. If you have to conditionally
"reyield" all the way up there, you miss out on potential important
optimizations.

This is related to "enums" and "pattern matching" too. The current pattern
matching proposal also doesn't have any optimizations either.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160315/339a87a9/attachment.html>


More information about the es-discuss mailing list