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:
Nathan Neulinger
Date:
August 18, 2001 07:35
Subject:
Re: How to redefine sub that has prototypes without warning at runtim e?
Message ID:
3B7E7D40.AE6CEB29@umr.edu
> A few options.  First, drop the () prototype.  That will kill the
> inlining and it will work as expected.  I don't think micro-efficiency
> is the issue here.
> 
> Second, map it to this:
> 
>     #define foo "foo"       sub foo { "foo" }
>     #undef  foo             { no warnings 'redefine';  undef &foo }
>     #define foo <stuff>     { no warnings 'redefine';  *foo = sub {<stuff>} }

Hmmm... That seems simple enough.

> Also, would it make more sense to say C<*foo = sub { undef }> rather
> than C<undef &foo>?

If you did that though, wouldn't &foo still be defined? If so, the code
that maps from

#undef foo
...
#ifndef foo
#define foo bar
#endif
...

wouldn't work right.

I wonder if it would be sufficient to put a "no warnings 'redefine'" at
the top of the generated files?

I may try a couple of these in h2ph and see if a small patch can correct
the problem/hide the symptom.

-- Nathan

------------------------------------------------------------
Nathan Neulinger                       EMail:  nneul@umr.edu
University of Missouri - Rolla         Phone: (573) 341-4841
CIS - Systems Programming                Fax: (573) 341-4216

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