-
Notifications
You must be signed in to change notification settings - Fork 15
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
[name bikeshed] Is "Context" the right name? #44
Comments
I think it's acceptable to have both, but if we had to pick one, I'd rather rename the decorator argument :-) Perhaps it's my React ecosystem bias, but "context" seems like the perfect name for what this proposal does. |
Maybe |
Just like "global" to me implies top level, "local" implies to me bottom level :-/ |
I'm really partial to calling these "async contexts", mainly because I absolutely hate the names that Node gave it (
|
There's also the fact that "async context" (or "async-local context") seems to refer to the general key-value map (the "snapshot", as we have sometimes called it). An |
altho to me "context" does imply the map. Maybe |
I believe the name AsyncLocalStorage came from the concept in C# called ThreadLocalStorage. I've also been interested in this concept for a while. I asked ChatGPT for some other name ideas (I particularly like AsyncScope and AsyncState):
|
In Project Loom for the JDK, they introduced final static ScopedValue<...> V = new ScopedValue<>();
// In some method
ScopedValue.where(V, <value>)
.run(() -> { ... V.get() ... call methods ... });
// In a method called directly or indirectly from the lambda expression
... V.get() ... In clojure, there is a concept called "dynamic binding" which is used similarly to bind a value in a scope. Many functions which start or run on a thread implement what is called "binding conveyance" which propagates dynamic bindings across async contexts. (def ^:dynamic *v* 1) ; dynamic values are typically denoted with earmuffs
(binding [*v* 2]
(future (print *v*)))
;; 2 I think that if consumers end up finding it useful outside of async contexts then it would be worth leaving that part out of the name. My 2c:
|
From what I gather, in scheme and its variants, this concept is called a fluid. Here is my suggestion: |
C# also have |
I tried looking up fluid scopes when Mark was talking about it in SES, and all I could find were esoteric CS papers and scheme. I'd really like to avoid this naming.
I wouldn't be opposed to |
after thinking through the motivation, a couple of suggestions for naming:
I am somewhat against the use of I am in support of I am also less against |
I ran the full thread through gpt 4 again 😬 and I'm sharing it here because I think it's insightful, especially for bikeshedding purposes: After reviewing the thread, it appears that there are a number of different naming suggestions with various pros and cons. My thoughts on the naming options discussed are:
Given the various trade-offs, I would suggest considering a combination of the names presented so far, such as "AsyncScopedValue" or "AsyncCaptureValue". This would emphasize both the asynchronous nature of the proposal and the capturing of values from the scope. However, it is important to ensure that the chosen name effectively communicates the concept to developers and avoids confusion with other features or concepts in the language. |
When I first heard about |
Maybe it's enough to distinguish between an individual value and the global mappings? In my initial design |
I'm supportive of distinguishing an individual instance and the global mappings, regarding #21. I'd avoid the term "dynamic" or "fluid" as they don't help to understand the concept productively. Async-"LocalStorage" is not a good term for the web platform as it may suggest relations to the LocalStorage API. A class in the namespace |
Note, Python use the name "contextvars" as module/namespace, and have classes |
I'd consider renaming AsyncContext to AsyncVariable (since an instance stands for a single variable--AsyncLocal or AsyncState or AsyncValue are reasonable alternatives), and using the term AsyncContext for AsyncResource/AsyncContext.Snapshot, as discussed in other issues like #21 . |
During today's meeting, we decided to introduce new naming. We'll need to settle the exact names naming, but we're aligned with changing the proposal in a way that should solve this issue.
This ties into #21 a bit. We'll be introducing 2 new classes, one to represent a value and one to represent a snapshot of the current context. So we could have a |
I don't have a concrete suggestion here, but context can be so broad that it can be meaningless. At the same time, we now have the decorator
context
argument, and while i don't think that collisions are imminent it might be worth discussing here.The text was updated successfully, but these errors were encountered: