-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Replace conditions with dynamically scoped variables #10602
Comments
What in tarnation is a dynamic[ally scoped] variable? |
@cmr Here are some quick results from googling:
|
@cmr thread-local variables with a fancy name. |
@nikomatsakis I think there is still the intent that you shouldn't have to manually write the code that restores the previous value as you pop your stack. But that should easily implementable via RAII; so yes, it basically comes down to a particular usage-pattern for thread-locals. |
Ok, I didn't realize it was dynamic scoping as I was already familiar with. fluid_key!(name, type, val) => static $name: Fluid<$type> = Fluid($val); // FluidRef is a non-sendable wrapper around *T since &'task isn't a thing fn fluid::set(key: &Fluid, val: T) -> FluidGuard { and the FluidGuard will just pop from the stack in TLS. It's basically just a scope guard version of conditions, rather than using Does this look about right? On Mon, Dec 16, 2013 at 5:48 AM, Niko Matsakis [email protected]:
|
Accepted "First major release", P-backcompat-libs |
Does this proposal actually remove the concept of conditions, or just alter how they are implemented? I rather like being able use conditions to set what behaviour should be taken when serious errors occur, especially since it lasts for all function calls within scope. It would be less elegant in my opinion to have to specify an enum to every function call to replace the functionality if it was removed. |
It just changes how they're implemented. On Fri, Dec 27, 2013 at 4:43 AM, Skrylar [email protected] wrote:
|
That sounds a bit similar to my (no longer working) port of the stacked locals I use in my Python libraries to rust: https://gist.github.com/mitsuhiko/213892b73873f9d20920 I gave up using this though, almost needs syntax support to not be really annoying. |
Conditions are gone now, and we're no longer using dynamic scope for anything in std. For the sake of portability @alexcrichton and I are inclined to preserve this characteristic of std. Dynamic scope and conditions are still worth exploring, but not in std please. Nominating for removal from milestone. |
On Wed, Feb 05, 2014 at 03:41:50PM -0800, Brian Anderson wrote:
+1 |
removing from milestone; reassigned P-low. |
Visiting for triage, carry on. RFC? |
Conditions have actually long since been removed, so this can be closed now. |
@alexcrichton of course the dynamically-scoped variables described in my comment above correspond to the new thread-local API that I believe Niko was talking about this last week. So while I do not mind this issue being closed, it is possible there is value in linking to the discussion in the comments above. Or maybe we're better off just starting fresh with a new ticket and/or RFC. |
I suspect a new TLS api will require an RFC, but we can leave this open in the meantime if you'd like. |
This issue has been moved to the RFCs repo: rust-lang/rfcs#300 |
Rustup r? `@ghost` changelog: none
Conditions are a special case of dynamic scope, and the few conditions we have in std that make sense, like
not_utf8
could simply be represented as a dynamic variable that represents the standard schemes for coping with unicode errors: failure, deletion, replacement char.Nominating.
The text was updated successfully, but these errors were encountered: