-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
proposal: context: add Scoped #44751
Comments
It sounds like you are suggesting that the compiler should recognize |
Yeah, that sounds fair. I was trying to indicate that like garbage collection or unsafe, this would not be a change to the language specification. |
It would be extremely unlikely for us to make a language change for a package like context. |
This proposal has been added to the active column of the proposals project |
Based on the discussion above, this proposal seems like a likely decline. |
No change in consensus, so declined. |
background
I an effort to defensively shunt off potential background goroutines, I find myself doing this frequently:
description
It strikes me that an alias of
context.Context
could be implemented such that this gets sugared implicitly:alternatives
Several proposals have spoken to removing or internalising
context.Context
in go2 and making it a first class language primitive. This would likely be prefer to this approach, but none of them went anywhere.drawbacks
This is pretty far down the magic rabbit hole, and maybe this is actually an anti-pattern, but
context.Context
is one of the sharpest interfaces I deal with regularly, and this seems to have benefits. If this is an anti pattern, what is the alternative?As this would be implemented in the runtime, it should not change the language spec. There is no requirement to modify any code, but it would likely turn out to be as viral as
context.Context
was.The text was updated successfully, but these errors were encountered: