develooper Front page | perl.perl5.porters | Postings from February 2003

Re: [PATCH] jumbo closure fix

Thread Previous | Thread Next
Dave Mitchell
February 26, 2003 13:33
Re: [PATCH] jumbo closure fix
Message ID:
On Wed, Feb 26, 2003 at 01:13:12PM -0800, Gurusamy Sarathy wrote:
> On Wed, 26 Feb 2003 20:39:37 GMT, Dave Mitchell wrote:
> >> IMO, the original warnings are rather misguided, because they
> >> ass_u_me a particular intent which may not be (in fact most
> >> often isn't, given that most people aren't trying to do anything
> >> fancy with closures) true.  It may be better to let these
> >> variables resolve as normal and let "use strict" do its thing.
> >
> >What is the thing that you want 'use strict' to do?
> Nothing it doesn't do already, i.e. fail with "Global symbol $x
> requires explicit package name ...".

You've lost me here a bit, I'm afraid. The kind of code that generates the
closure warnings doesn't generate such 'global sym' messages under use
strict, eg

[davem@percy 18779]$ perl -we ' sub f { my $x; sub g { $x } }'
Variable "$x" will not stay shared at -e line 1.

[davem@percy 18779]$ perl -we 'use strict; sub f { my $x; sub g { $x } }'
Variable "$x" will not stay shared at -e line 1.

I quite like the like the closure warnings because it flags setups that
are rarely what the user wanted; even if they don't fully (or even
partially!) understand what the message means, its probably better than
Perl being totally silent, and then their code still behaving in a
mysterious way. The 0.0001% of the population who understand the
implications of sub f { my $x; sub g {$x} } and have a valid use for it
can always chuck in a no warnings 'closure'.

"There's something wrong with our bloody ships today, Chatfield."
Admiral Beatty at the Battle of Jutland, 31st May 1916.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About