Opposition to Python type hints
Opposition to Python type hints
Posted May 7, 2015 17:42 UTC (Thu) by ibukanov (subscriber, #3942)In reply to: Opposition to Python type hints by niner
Parent article: Opposition to Python type hints
~/s> cat x.pl
use strict;
my $a = 10;
if ($a) {
print "OK\n";
} else {
print $b . $b . "\n";
}
~/s> perl -w x.pl
OK
No warnings or errors about undeclared $b. What did I miss?
Posted May 7, 2015 17:49 UTC (Thu)
by niner (subscriber, #26151)
[Link]
my @sorted = sort { $a <=> $b } @unsorted;
Try your example with $x and $y and you'll get:
~> perl x.pl
Yes, that's surprising behavior and it's one of the reasons for Perl 6 being a breaking change. Of course, $a and $b are not exactly good variable names anyway :)
Opposition to Python type hints
Global symbol "$y" requires explicit package name at x.pl line 6.
Global symbol "$y" requires explicit package name at x.pl line 6.
Execution of x.pl aborted due to compilation errors.
