A bug in get_iplayer-3.01?

Ralph Corderoy ralph at inputplus.co.uk
Sun Jun 18 04:24:50 PDT 2017


Hi Richard,

> I was frantically reading about the scope of variables.  My background
> is Algol 60 and PLI where a block is a compound statement with local
> declarations.  I gather in Perl it's the other way round.

No, I think it's the same as those language, C.  Running

    $n = 1;

    sub foo {
	print "b $n\n";
	my $n = 2;
	print "c $n\n";
	for (my $i = 0; $i < 2; $i++) {
	    print "d $n\n";
	    if ($i == 0) {
		my $n = 3; # Never printed.
	    } else {
		$n = 4; # No my.
	    }
	    print "e $n\n";
	}
	print "f $n\n";
    }

    print "a $n\n";
    foo;
    print "g $n\n";

gives

    a 1
    b 1
    c 2
    d 2
    e 2
    d 2
    e 4
    f 4
    g 1

> I hear what you say about C++, but I find it easier than Python.

If that's because you like its types-defined-at-compile-time nature then
Go will appeal.

    func main() {
	    type (
		    foo int
		    bar int
	    )
	    var (
		    f foo
		    b bar
	    )
	    f = 42
	    b = f
    }

"cannot use f (type foo) as type bar in assignment".

-- 
Cheers, Ralph.
https://plus.google.com/+RalphCorderoy



More information about the get_iplayer mailing list