As mentioned in the previous post, I found Perl has problems here:
Perl's inner() enters the global scope, even from within outer()
Vs.
Python does the scoping I expect, though not any compile time checking for undefined functions. Though Perl doesn't here, either, even with 'use strict;'. Well, I suppose it's possible that in these languages, outer() could have done something to define inner() before it was called.
[Zefiris:0] cat unbound.pl
sub outer {
sub inner {
print "inside inner\n";
}
print "inside outer\n";
}
outer();
inner();
[Zefiris:0] perl unbound.pl
inside outer
inside inner
Perl's inner() enters the global scope, even from within outer()
Vs.
[Zefiris:0] cat unbound.py
def outer():
def inner():
print("inside inner")
print("inside outer")
outer()
inner()
[Zefiris:0] python unbound.py
inside outer
Traceback (most recent call last):
File "unbound.py", line 8, in
inner()
NameError: name 'inner' is not defined
Python does the scoping I expect, though not any compile time checking for undefined functions. Though Perl doesn't here, either, even with 'use strict;'. Well, I suppose it's possible that in these languages, outer() could have done something to define inner() before it was called.