Re: Re: One-shot Delimited Continuations with Effect Handlers

2019-12-25 Thread kai zhu
the usage-scenario is not compelling. the same effect can be achieved in 12-lines of throwaway-code (i copy pasted into console), with less tech-debt: $ node -e ' var nameList = [null, "Gendry"]; nameList.forEach(async function (name) { // if name is null, then wait 1000ms, and default to "Ary

Re: Re: One-shot Delimited Continuations with Effect Handlers

2019-12-24 Thread Bruno Macabeus
Hello for all, I know that this discuss is a little old, but I just found it now and I think that it is still useful at this moment. So I created a very simple Babel plugin to taste and validate the Sebatian's idea: https://github.com/macabeus/js-proposal-algebraic-effects

Re: One-shot Delimited Continuations with Effect Handlers

2018-11-06 Thread 森建
Sorry for my hasty reply, the restriction seems to be not related to Algebraic Effects. But I think that Algebraic Effects specifications is useful for a pure implementation. On 2018/11/06 18:44, 森建 wrote: React Hooks, a new feature of React v16.7.0-alpha, is a hacky implementation, so there

Re: One-shot Delimited Continuations with Effect Handlers

2018-11-06 Thread 森建
React Hooks, a new feature of React v16.7.0-alpha, is a hacky implementation, so there are restrictions that must be called in order. https://reactjs.org/docs/hooks-rules.html One of React members says below: > Finally, if you’re a functional programming purist and feel uneasy about React rely

Re: One-shot Delimited Continuations with Effect Handlers

2016-03-19 Thread Sebastian Markbåge
> > Although it is more work for the person writing code, I believe having > to explicitly use keywords (await or yield) in function bodies makes > it very clear what is happening, and ultimately leads to better code > with less potential for human error in the long run. > ... > The beauty of JavaS

Re: One-shot Delimited Continuations with Effect Handlers

2016-03-19 Thread /#!/JoePea
The effect addition to try-catch seems like some sort of hacky workaround, that would get the job done, but then would make try-catch be used for purposes other than catching errors, which defeats it's original purpose. I think it's important to keep that error-based meaning and not mix it with any

Re: One-shot Delimited Continuations with Effect Handlers

2016-03-18 Thread Sebastian Markbåge
> > Isn't the problem we actually need to solve here the fact we're not able > to control scheduling or context in async functions? > Other languages with async functions like Python and C# provide the means > to control the scheduling of async functions. > Algebraic effects also allows the side-e

RE: One-shot Delimited Continuations with Effect Handlers

2016-03-16 Thread Benjamin Gruenbaum
> async functions only address the async use case and they're all scheduled on a simple micro-task queue. We need fine grained control over scheduling. Perhaps Zones can help a bit with that but that's just one of severals concepts that need this. Isn't the problem we actually need to solve here t

Re: One-shot Delimited Continuations with Effect Handlers

2016-03-15 Thread Sebastian Markbåge
It's possible that this pattern matching feature can be decoupled into a separate proposal though. You'd need a way to call an iterator but only receive specific matches and reyield the rest. On Tue, Mar 15, 2016 at 6:05 PM, Sebastian Markbåge wrote: > > Perhaps if there was a way to wrap any ar

Re: One-shot Delimited Continuations with Effect Handlers

2016-03-15 Thread Sebastian Markbåge
> 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 a

Re: One-shot Delimited Continuations with Effect Handlers

2016-03-15 Thread Ben Newman
Ok, I think I understand how your needs differ from the async/relaxed-await idea. You need a way to - extract values from deeply nested yields, which is not allowed by await expressions, - resume execution whenever you choose, which is a decision await expressions make for you, i.e. th

Re: One-shot Delimited Continuations with Effect Handlers

2016-03-15 Thread Ben Newman
What if we simply allowed await expressions anywhere in the call stack of an async function, rather than only in the bodies of async functions? That would give us all the power of "yielding deep in a fiber" with a much more familiar syntax, and an easy way to capture effects, since an async functio

Re: One-shot Delimited Continuations with Effect Handlers

2016-03-15 Thread Sebastian Markbåge
async functions only address the async use case and they're all scheduled on a simple micro-task queue. We need fine grained control over scheduling. Perhaps Zones can help a bit with that but that's just one of severals concepts that need this. It doesn't solve other more general generator use ca