Of course that makes for implicit global dependency, unless you pass a context manager ref around almost like Go does
But at least it'd help scope resources instead of using globals while avoiding a coloring problem (see Go context where if an interface doesn't take context one has to find an alternative means to passing context through)
In Python, thread-local variables and ContextVars get you quite a bit of the way there.
You can even implement “without” patterns, albeit only as runtime checks - though if you’re following the React practice that hooks must be called unconditionally, and you have test coverage, you essentially have compile time checks.
And, speaking of coloring problems, if you’re running on gevent, both become greenlet-local, and you can benefit from concurrency limited only by working memory, without needing explicit async code.
Calling useContext(ctx) looks up nearest parent call frame defining setContext(ctx, value)
Of course that makes for implicit global dependency, unless you pass a context manager ref around almost like Go does
But at least it'd help scope resources instead of using globals while avoiding a coloring problem (see Go context where if an interface doesn't take context one has to find an alternative means to passing context through)