From: Chip Salzenberg Date: Tue, 7 Jan 1997 23:52:00 +0000 (+1200) Subject: Re: constant function inlining X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4cee8e801dff327aea080085070903d41783ea55;p=p5sagit%2Fp5-mst-13.2.git Re: constant function inlining (this is the same change as commit f0893e72a8aa916a77953ff2f1847494d1527fb8, but as applied) --- diff --git a/pod/perldiag.pod b/pod/perldiag.pod index a9bdb9b..fb0a2d7 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -812,6 +812,12 @@ to 01411. Octal constants are introduced with a leading 0 in Perl, as in C. (W) You tried to do a connect on a closed socket. Did you forget to check the return value of your socket() call? See L. +=item Constant subroutine %s redefined + +(S) You redefined a subroutine which had previously been eligible for +inlining. See L for commentary and +workarounds. + =item Corrupt malloc ptr 0x%lx at 0x%lx (P) The malloc package that comes with Perl had an internal failure. diff --git a/pod/perlsub.pod b/pod/perlsub.pod index 6bd3fe8..bd3eb18 100644 --- a/pod/perlsub.pod +++ b/pod/perlsub.pod @@ -754,6 +754,21 @@ starts scribbling on your @_ parameter list. This is all very powerful, of course, and should be used only in moderation to make the world a better place. +If you redefine a subroutine which was eligible for inlining you'll get +a mandatory warning. (You can use this warning to tell whether or not a +particular subroutine is considered constant.) The warning is +considered severe enough not to be optional because previously compiled +invocations of the function will still be using the old value of the +function. If you need to be able to redefine the subroutine you need to +ensure that it isn't inlined, either by dropping the C<()> prototype +(which changes the calling semantics, so beware) or by thwarting the +inlining mechanism in some other way, such as + + my $dummy; + sub not_inlined () { + $dummy || 23 + } + =head2 Overriding Builtin Functions Many builtin functions may be overridden, though this should be tried