Commit 30729187 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Test eval() and closure interaction.

Unlike some other languages, it looks like eval()
doesn't force the capturing of outer variables.

Good thing too, since pretty much any function call
could theoretically end up resolving to eval().
parent b2f7eddc
# expected: fail
# - eval not implemented
# - closures not implemented
x = 2
def wrap():
x = 1
y = 3
# The eval('x') in this function will resolve to the global scope:
def inner1():
y
print locals()
print eval('x')
inner1()
# The eval('x') in this function will resolve to the closure, since
# there is a textual reference to x which causes it to get captured:
def inner2():
x
print locals()
print eval('x')
inner2()
wrap()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment