summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTony Bowden <tony@kasei.com>2001-08-25 16:13:14 +0100
committerAbhijit Menon-Sen <ams@wiw.org>2001-08-25 18:28:43 +0000
commit04b85669c399942716cc222829b1dae05a1ed7c2 (patch)
tree392a127f9b25c9243866ca12a0038fe692ab7cb8 /lib
parentacbe17fc4e3c447b48d980c85cdc81b3190f66eb (diff)
downloadperl-04b85669c399942716cc222829b1dae05a1ed7c2.tar.gz
Re: 'can' with undefined subs
Message-Id: <20010825151314.B11788@soto.kasei.com> p4raw-id: //depot/perl@11751
Diffstat (limited to 'lib')
-rw-r--r--lib/UNIVERSAL.pm9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/UNIVERSAL.pm b/lib/UNIVERSAL.pm
index a66f8d5328..a9cb478b43 100644
--- a/lib/UNIVERSAL.pm
+++ b/lib/UNIVERSAL.pm
@@ -45,6 +45,15 @@ C<can> checks if the object has a method called C<METHOD>. If it does
then a reference to the sub is returned. If it does not then I<undef>
is returned.
+C<can> cannot know whether an object will be able to provide a method
+through AUTOLOAD, so a return value of I<undef> does not necessarily mean
+the object will not be able to handle the method call. To get around
+this some module authors use a forward declaration (see L<perlsub>)
+for methods they will handle via AUTOLOAD. For such 'dummy' subs, C<can>
+will still return a code reference, which, when called, will fall through
+to the AUTOLOAD. If no suitable AUTOLOAD is provided, calling the coderef
+will cause an error.
+
C<can> can be called as either a static or object method call.
=item VERSION ( [ REQUIRE ] )