[snip ... why doesn't "my $i if 0;" generate a warning under "use
warnings;"]
Glenn Linderman wrote:
Partly because the behaviour was probably implemented unintentionally
(hence no original warning or error), and has been treated (once
discovered by those nefarious end-user types) as a feature in some code.
Adding a warning then makes existing code noisier than it was, so the
feature can only be added to "blead" not "maint" (if you are familiar
with Perl development terminology). I _think_ I recall seeing comments
on p5p that there is now a warning for that construct in blead? At
least it was discussed. Try downloading Perl 5.9.x and see, if you
really want to be sure.
Anyway, it is currently a "known gotcha"... there is no other
programming language that I am aware of that even allows such syntax, to
"conditionally declare" variables, so it is surprising that you even
attempted such... which has kept this from being a bigger problem than
it would be otherwise.
A (deprecated) warning was added in 5.9.1 according to this p5p summary:
http://www.nntp.perl.org/group/perl.perl5.summary/98
<quote>
Rafael noted also that the regression tests produce lots of warnings
"Deprecated use of my() in conditional", referring to the dubious and
now deprecated construct
my $foo = $bar if $quux;
So the warning is maybe too noisy (although it indicates a bug waiting
to happen.) Rafael and Dave Mitchell proposed some alternatives, but
the current form of the warning is likely to go into 5.9.1, even if
it's made lighter afterwards.
</quote>
I has been discussed on p5p more recently (in the last few months) but I
can't quickly turn p a reference.
Regards,
Rob.
--
Robert May
Win32::GUI, a perl extension for native Win32 applications
http://perl-win32-gui.sourceforge.net/
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs