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

Global variables #12

Open
bartvm opened this issue Jan 17, 2018 · 0 comments
Open

Global variables #12

bartvm opened this issue Jan 17, 2018 · 0 comments

Comments

@bartvm
Copy link
Member

bartvm commented Jan 17, 2018

See #4 (comment) and subsequent discussion. Related to #11.

Python's name bindings are mutable.

x = 1
def f():
    return x
x = 2
assert f() == 2

This can be handled by reparsing the function each time it is called, to ensure that the current values of globals are used. A more efficient way would be to only redo the parsing when the values have changed; to make globals explicit as parameters to a main function that the other functions are closed over; or to introduce environment objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant