in reply to Re: A short whishlist of Perl5 improvements leaping to Perl7
in thread A short whishlist of Perl5 improvements leaping to Perl7

Yes, simple lexical scoping (a variable is known from its point of declaration to end of scope) and deterministic destructors are two things I find enjoyable when using both Perl and C++ ... and I feel confused and frustrated when forced to use the ugly and complex Python scoping workarounds introduced with the global and nonlocal (sic) keywords.

To give an illustrative example, Python happily compiles and runs the typo-riddled program below, printing vanilla:

icecream_flavour = 'vanilla' # ... if 1: icecream_flavor = 'chocolate' print(icecream_flavour)
while Perl detects the typo at compile-time:
use strict; my $icecream_flavour = 'vanilla'; # ... if (1) { $icecream_flavor = 'chocolate'; } print $icecream_flavour;
with the error message:

Global symbol "$icecream_flavor" requires explicit package name (did you forget to declare "my $icecream_flavor"?) at line 5.
Execution of aborted due to compilation errors.

Update: As pointed out by LanX below, this is an unfortunate example of Python violating the Zen of Python, specifically "Explicit is better than implicit". I feel it further violates "Beautiful is better than ugly" and "Simple is better than complex" and "Errors should never pass silently" and "If the implementation is hard to explain, it's a bad idea".

See also (further update):