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

Discussion in 'Perl Misc' started by Andrew, Jul 13, 2005.

  1. Andrew

    Andrew Guest

    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
    Andrew, Jul 13, 2005
    #1
    1. Advertising

  2. 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.
    Brian McCauley, Jul 13, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. john
    Replies:
    0
    Views:
    418
  2. Olaf Petzold

    anon enums porting problem

    Olaf Petzold, Nov 8, 2005, in forum: C++
    Replies:
    0
    Views:
    347
    Olaf Petzold
    Nov 8, 2005
  3. neilmac
    Replies:
    2
    Views:
    625
    mcdjnaja
    Feb 7, 2008
  4. Victor Porton
    Replies:
    7
    Views:
    103
    TonyV
    Dec 11, 2007
  5. cartercc

    variables that won't stay shared

    cartercc, Mar 2, 2009, in forum: Perl Misc
    Replies:
    3
    Views:
    156
    ccc31807
    Mar 3, 2009
Loading...

Share This Page