Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Perl Misc (http://www.velocityreviews.com/forums/f67-perl-misc.html)
-   -   no "won't stay shared" warning for "use constant" anon subs (http://www.velocityreviews.com/forums/t893280-no-wont-stay-shared-warning-for-use-constant-anon-subs.html)

Andrew 07-13-2005 06:14 PM

no "won't stay shared" warning for "use constant" anon subs
 
Seems like we're missing the "will not stay shared" warning for anon
subs declared via "use constant". Is this a bug? Please cc: me on
replies.

use strict;
use warnings;
sub foo{
my($c,$d,$e)=("x","y","z");
my $bob=sub{$c=$_[0] if @_};
use constant sue => sub{$d=$_[0] if @_}; #line 6
sub hal {$e=$_[0] if @_} #line 7
$bob->(@_);
sue->(@_);
hal(@_);
print "c=$c d=$d e=$e\n";
}

foo("q");
foo();
foo("a");
foo("b");
__END__


output:
------------------------
Variable "$e" will not stay shared at testshared.pl line 7.
c=q d=q e=q
c=x d=y e=z
c=a d=y e=z
c=b d=y e=z


Brian McCauley 07-13-2005 07:05 PM

Re: no "won't stay shared" warning for "use constant" anon subs
 

Andrew wrote:

> Seems like we're missing the "will not stay shared" warning for anon
> subs declared via "use constant". Is this a bug?


No, you can't expect Perl to detect you shooting yourself in the foot by
bouncing off three walls.

> Please cc: me on replies.


Post here, read here.


All times are GMT. The time now is 12:29 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.