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

Python runtime name resolution #11

Open
bartvm opened this issue Jan 17, 2018 · 1 comment
Open

Python runtime name resolution #11

bartvm opened this issue Jan 17, 2018 · 1 comment

Comments

@bartvm
Copy link
Member

bartvm commented Jan 17, 2018

See #4 (comment) and subsequent discussion.

Python's runtime name resolution means that the name binding of a closed variable can be changed.

def f():
    x = 3
    def g():
        return x
    x = 4
    def h():
        return x
    return g, h

g, h = f()
assert g() == h()

We should either disallow this, specialize g multiple times, or perform name resolution at runtime instead of at compile-time.

This was referenced Jan 17, 2018
@bartvm
Copy link
Member Author

bartvm commented Jan 22, 2018

Relevant quote from the Python documentation:

On the other hand, the actual search for names is done dynamically, at run time — however, the language definition is evolving towards static name resolution, at “compile” time, so don’t rely on dynamic name resolution! (In fact, local variables are already determined statically.)

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