-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pecan vs nadakoroutines #15
Comments
hi @nadako, |
I have to think how coroutines play with serialization. I don't think you can serialize coroutines in general, since there are function pointers binding them together and such and I'm not even sure that's something that should be supported by the coroutine mechanism itself rather than a framework on top, but we should look into enabling such frameworks to do that, yeah :) |
some language and framework like racket(scheme) and seaside/smalltalk support continuation serialization https://docs.racket-lang.org/web-server/stateless.html#%28part._.Serializable_.Continuations%29 |
in general the serialization isn't for the pointer functions but only for the internal data |
I made a separate issue here #16 |
I'm going to close this as it's not really an actionable issue. There's an experimental branch now here HaxeFoundation/haxe#10128 where we can discuss and refine API. |
since pecan is the currently the most promising macro implementation for coroutines and its idea is pretty close to what we have in mind in this proposal, we can use it (or its fork) as a proving ground before moving the implementation into the compiler.
here I outline the current key differences between pecan and the proposed design (calling it
nadakoroutines
for brevity):starting
pecan
CoroutineFactory
classesCoroutineFactory
instances haverun
method that receives arguments and return anICo
instancenadakoroutines
Suspend<TFunc>
typeSuspend<TFunc>
havestart
method that receives arguments and continuation and hasVoid
return typesuspending
pecan
ICo
) which can be passed around and provides methods for suspending, resuming and terminating the coroutine@:pecan.action
or@:pecan.accept
will automatically pass coroutine instance (ICo
) as an argument to those methods, allowing for the same control as in the previous variantnadakoroutines
suspendCoroutine
that can be called to explicitly suspend the current coroutine. this method receives a function to be called immediately after the coroutine is suspended and this function receives the continuation for resuming the coroutineresuming
pecan
ICo
) methods, liketick
,give
,take
, etc.@:pecan.accept
methods receive a "return value" callback, calling it will automatically resume the coroutine and give the value to itnadakoroutines
suspendCoroutine
, the continuation is exposed to the function given to it and must be explicitly calledpassing values
pecan
accept()
andyield()
"magic" methods to receive or give values to the outside world. the outside world operates throughICo
which has correspondinggive
andtake
methods@:pecan.action
methods can take any arguments@:pecan.accept
methods can take any arguments and return the value back to coroutine with a special callbacknadakoroutines
start
method receives a continuation along with the other arguments, this continuation will be invoked when the coroutine terminates, passing the return value to the outside worldsuspendCoroutine
method receives a continuation that is used to both resume the coroutine and pass the "accepted" result to itextra features
pecan
The text was updated successfully, but these errors were encountered: