On Wed, Aug 16, 2017 at 1:13 PM, Stefan Krah <ste...@bytereef.org> wrote:
> On Wed, Aug 16, 2017 at 12:40:26PM -0400, Yury Selivanov wrote:
>> On Wed, Aug 16, 2017 at 12:08 PM, Stefan Krah <ste...@bytereef.org> wrote:
>> > On Wed, Aug 16, 2017 at 11:00:43AM -0400, Yury Selivanov wrote:
>> >> "Context" is an established term for what PEP 550 tries to accomplish.
>> >> It's used in multiple languages and runtimes, and while researching
>> >> this topic I didn't see anybody confused with the concept on
>> >> StackOverflow/etc.
>> >
>> > For me a context is a "single thing" that is usually used to thread state
>> > through functions.
>> >
>> > I guess I'd call "environment" what you call "context".
>>
>> "environment" is also an overloaded term, and when I hear it I usually
>> think about os.getenv().
>
> Yeah, I usually think about symbol tables.  FWIW, I find this terminology
> quite reasonable:
>
> https://hackernoon.com/execution-context-in-javascript-319dd72e8e2c

Thanks for the link!  I think it actually explains the JS language spec
wrt how scoping of regular variables is implemented.

> The main points are ExecutionContextStack/FunctionalExecutionContext
>
> vs. ExecutionContext/LocalContext.

While I'm trying to avoid using scoping terminology for PEP 550, there's
one parallel -- as with regular Python scoping you have global variables
and you have local variables.

You can use the locals() to access to your local scope, and you can use
globals() to access to your global scope.

Similarly in PEP 550, you have your LocalContext and ExecutionContext.
We don't want to call ExecutionContext a "Global Context" because
it is fundamentally OS-thread-specific (contrary to Python globals).

LocalContexts are created for threads, generators, coroutines and are
really similar to local scoping.  Adding more names for local contexts
like CoroutineLocalContext, GeneratorLocalContext won't solve anything
either.  All in all, Local Context is what its name stands for -- it's a
local context for your current logical scope, be it a coroutine or a
generator.

At this point PEP 550 is very different from ExecutionContext in .NET,
but there are still many similarities.  That's a +1 to keep its current name.

ExecutionContextStack and ExecutionContextChain reflect the
implementation of PEP 550 on some level, but for most Python users
they won't mean anything. If they want to learn how EC works, they
just need to read the PEP (or documentation).  Otherwise they will
just use the ContextKey API and it should just work for them.

So IMO, ExecutionContext and LocalContext are really the best
names of all that were proposed so far.

Yury
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to