diff options
author | Roderick Schertler <roderick@gate.net> | 1997-01-07 15:27:50 -0500 |
---|---|---|
committer | Chip Salzenberg <chip@atlantic.net> | 1997-01-08 11:52:00 +1200 |
commit | f0893e72a8aa916a77953ff2f1847494d1527fb8 (patch) | |
tree | 828edac35788cee3d02039e7e94dbc6651714d05 | |
parent | a4165598218d6f4027c60d743c1ec7eb33232258 (diff) | |
download | perl-f0893e72a8aa916a77953ff2f1847494d1527fb8.tar.gz |
Re: constant function inlining
On Tue, 7 Jan 1997 18:21:28 +0000, Tim Bunce <Tim.Bunce@ig.co.uk> said:
>
> A few words about redefining [constant] functions would be worthwhile.
Right, patch attached.
p5p-msgid: <pzk9pp1b95.fsf@eeyore.ibcinc.com>
-rw-r--r-- | pod/perldiag.pod | 6 | ||||
-rw-r--r-- | pod/perlsub.pod | 17 |
2 files changed, 22 insertions, 1 deletions
diff --git a/pod/perldiag.pod b/pod/perldiag.pod index a9bdb9b1d3..fb0a2d76c0 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<perlfunc/connect>. +=item Constant subroutine %s redefined + +(S) You redefined a subroutine which had previously been eligible for +inlining. See L<perlsub/"Constant Functions"> 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 6bd3fe8d84..fa14a7fe2f 100644 --- a/pod/perlsub.pod +++ b/pod/perlsub.pod @@ -752,7 +752,22 @@ in @foo. And the split() gets called in a scalar context and 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. +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 |