Skip to content
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

Scoped variables not working? #357

Open
forrestbao opened this issue Jul 5, 2023 · 3 comments
Open

Scoped variables not working? #357

forrestbao opened this issue Jul 5, 2023 · 3 comments
Labels
bug Something isn't working kernel Critical issues related to code execution

Comments

@forrestbao
Copy link
Collaborator

See this repo https://app.codepod.io/repo/57p4jkgi49412wsdr1bt

image

@forrestbao forrestbao added bug Something isn't working kernel Critical issues related to code execution labels Jul 5, 2023
@lihebi
Copy link
Collaborator

lihebi commented Jul 7, 2023

This is the "lexical scoping": descendant scopes can access ancestor scope's variables and functions. Implemented in #284.

@lihebi
Copy link
Collaborator

lihebi commented Jul 8, 2023

But this isn't always intuitive and convenient. I think we should implement the nonlocal keyword in Python.

@forrestbao
Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working kernel Critical issues related to code execution
Projects
None yet
Development

No branches or pull requests

2 participants