mindstalk: (escher)
As mentioned in the previous post, I found Perl has problems here:

[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.

Profile

mindstalk: (Default)
mindstalk

February 2026

S M T W T F S
12 34567
89 10111213 14
1516 171819 2021
22232425262728

Most Popular Tags

Expand Cut Tags

No cut tags

Style Credit

Page generated 2026-02-20 18:47
Powered by Dreamwidth Studios