codepod
codepod copied to clipboard
Scoped variables not working?
See this repo https://app.codepod.io/repo/57p4jkgi49412wsdr1bt
This is the "lexical scoping": descendant scopes can access ancestor scope's variables and functions. Implemented in #284.
But this isn't always intuitive and convenient. I think we should implement the nonlocal keyword in Python.
Should the "access" of a child scope be read-only by default? Thus, a scope can access variables in its parent scope but cannot change its value in the parent scope unless declared global or nonlocal?
This is the case for functions. A function definition is not exposed to the parent scope until @export'ed. This well aligns with the tradition in programming.