-
Notifications
You must be signed in to change notification settings - Fork 8
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
Cancelation Problem #813
Comments
Indeed, that will simplify coding for loops but in terms of clean and nice graceful shutdown it might me required to customise this process and gave programmer the ability to exit on his own conditions or his own cases making the default behaviour works only if custom cancellation token processing omitted completely in user space code and not in library code they are using |
Please take a look into the ##custodians section: https://nikhilism.com/post/2023/racket-beyond-languages/ |
Also, in general about CML and different languages and ideas: https://wingolog.org/archives/2016/09/21/is-go-an-acceptable-cml |
@default-writer thanks, this issue doesn't propose (yet) some solution e.g. automatic cancelation (I don't have clear vision how this could work at the moment), but your point is valid - in case there will be something like that, we need to be sure it scales well for cases where custom logic is needed |
In Go there's a way to stop goroutine from executing. It's a simple pattern where all you need to do is to pass a channel to that function. That functions must guarantee (compiler doesn't enforce though) to stop as soon as channel will be closed.
Go design extends this pattern with first class support for
for
loops where you can range over channel messages. For loop will automatically break after channel is closed. Another construct that is frequently used with this pattern isselect
with case for cancelation channel. Go does even next step and implements half of this pattern withcontext.Context
data-type that hasDone()
method that returns a channel you can block on. As soon as context is closed (by timeout or manual call tocancel
func), the channel thatDone()
returns also closes.Go however solves two problems with this data-type, it also allows to use it as a context in react-sense i.e. to share data without explicit drilling. That is a separate problem #812 that doesn't have to be solved in Nevalang exactly this way. Even thought it could be.
The text was updated successfully, but these errors were encountered: