summaryrefslogtreecommitdiff
path: root/pod/perlsub.pod
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2001-12-17 17:37:18 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2001-12-17 21:59:07 +0000
commit77bc9082d5f32bccec35cc0887964884d1ca682b (patch)
tree902ecf904b2c71662f51329fb39d3cc40d532d9a /pod/perlsub.pod
parent74f3d116ec4be35200e42be295e61a420b376261 (diff)
downloadperl-77bc9082d5f32bccec35cc0887964884d1ca682b.tar.gz
[PATCH] Re: chomp/chop prototype changed?
Date: Mon, 17 Dec 2001 16:37:18 +0100 Message-ID: <20011217163718.A2292@rafael> Subject: Re: [PATCH] Re: chomp/chop prototype changed? From: Rafael Garcia-Suarez <rgarciasuarez@free.fr> Date: Mon, 17 Dec 2001 23:17:06 +0100 Message-ID: <20011217231706.A730@rafael> p4raw-id: //depot/perl@13747
Diffstat (limited to 'pod/perlsub.pod')
-rw-r--r--pod/perlsub.pod24
1 files changed, 24 insertions, 0 deletions
diff --git a/pod/perlsub.pod b/pod/perlsub.pod
index 4329c161ff..efadf8f848 100644
--- a/pod/perlsub.pod
+++ b/pod/perlsub.pod
@@ -1194,6 +1194,30 @@ a properly written override. For a fully functional example of overriding
C<glob>, study the implementation of C<File::DosGlob> in the standard
library.
+When you override a built-in, your replacement should be consistent (if
+possible) with the built-in native syntax. You can achieve this by using
+a suitable prototype. To get the prototype of an overridable built-in,
+use the C<prototype> function with an argument of C<"CORE::builtin_name">
+(see L<perlfunc/prototype>).
+
+Note however that some built-ins can't have their syntax expressed by a
+prototype (such as C<system> or C<chomp>). If you override them you won't
+be able to fully mimic their original syntax.
+
+The built-ins C<do>, C<require> and C<glob> can also be overriden, but due
+to special magic, their original syntax is preserved, and you don't have
+to define a prototype for their replacements. (You can't override the
+C<do BLOCK> syntax, though).
+
+C<require> has special additional dark magic: if you invoke your
+C<require> replacement as C<require Foo::Bar>, it will actually receive
+the argument C<"Foo/Bar.pm"> in @_. See L<perlfunc/require>.
+
+And, as you'll have noticed from the previous example, if you override
+C<glob>, the C<E<lt>*E<gt>> glob operator is overriden as well.
+
+Finally, some built-ins (e.g. C<exists> or C<grep>) can't be overriden.
+
=head2 Autoloading
If you call a subroutine that is undefined, you would ordinarily