summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChip Salzenberg <chip@atlantic.net>1997-01-08 11:52:00 +1200
committerChip Salzenberg <chip@atlantic.net>1997-01-08 11:52:00 +1200
commit4cee8e801dff327aea080085070903d41783ea55 (patch)
tree5fa96bad50128892599acd4b04a9960e098837cb
parenta4165598218d6f4027c60d743c1ec7eb33232258 (diff)
downloadperl-4cee8e801dff327aea080085070903d41783ea55.tar.gz
Re: constant function inlining
(this is the same change as commit f0893e72a8aa916a77953ff2f1847494d1527fb8, but as applied)
-rw-r--r--pod/perldiag.pod6
-rw-r--r--pod/perlsub.pod15
2 files changed, 21 insertions, 0 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..bd3eb18154 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