develooper Front page | perl.perl5.porters | Postings from August 2001

Re: How to redefine sub that has prototypes without warning at runtim e?

Thread Previous | Thread Next
From:
Kurt D. Starsinic
Date:
August 17, 2001 22:56
Subject:
Re: How to redefine sub that has prototypes without warning at runtim e?
Message ID:
20010817225636.D25780@wolfetech.com
On Sat, Aug 18, 2001 at 01:33:07AM -0400, Michael Schwern wrote:
> On Fri, Aug 17, 2001 at 04:04:03PM -0500, Neulinger, Nathan wrote:
> > The following snippet generates the following warning:
> > 
> > ---
> > sub foo () { print "foo"; }
> > undef &foo;
> > eval 'sub foo () { print "bar"; }';
> > ---
> 
> Drop the C<undef &foo> and use a C<no warnings 'redefine'>
> 
>     {
>         no warnings 'redefine';
>         eval q{ sub foo () { print "bar"; } };
>     }

    Pardon me for stepping in; I know the context here (it's h2ph
related).  Given the mapping . . .

        #define foo "foo"               ->      sub foo () { "foo"; }
        #undef  foo                     ->      undef &foo;
        #define foo <something complex> -> eval 'sub foo () { <blah> }'

    . . . and given the following input . . .

        #define foo "foo"
        #undef  foo
        #define foo <something complex>

    . . . is there an alternate mapping that wouldn't trigger a warning?

    - Kurt


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About