From: Casey West Date: Thu, 24 Apr 2003 08:18:42 +0000 (-0400) Subject: Re: [COMPLETE PATCH lib/UNIVERSAL.pm] RE: [perl #22018] UNIVERSAL documentatio n... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a2b59c1fd3e639743fd29c128802456a1105afef;p=p5sagit%2Fp5-mst-13.2.git Re: [COMPLETE PATCH lib/UNIVERSAL.pm] RE: [perl #22018] UNIVERSAL documentatio n contradicts itself Message-ID: <20030424121842.GW34510@geeknest.com> p4raw-id: //depot/perl@19348 --- diff --git a/lib/UNIVERSAL.pm b/lib/UNIVERSAL.pm index 92b4fcd..5c28f9f 100644 --- a/lib/UNIVERSAL.pm +++ b/lib/UNIVERSAL.pm @@ -41,20 +41,42 @@ C provides the following methods and functions: =over 4 -=item $obj->isa( TYPE ), CLASS->isa( TYPE ), isa( VAL, TYPE ) +=item C<< $obj->isa( TYPE ) >> - C is a package name - $obj is a blessed reference or a string containing a package name - C is a package name - C is any of the above or an unblessed reference +=item C<< CLASS->isa( TYPE ) >> -When used as an instance or class method (C<$obj->isa( TYPE )>), C -returns I if $obj is blessed into package C or inherits from -package C. +=item C -When used as a class method (Cisa( TYPE )>; sometimes referred to as a -static method), C returns I if C inherits from (or is itself) -the name of the package C or inherits from package C. +Where + +=over 4 + +=item C + +is a package name + +=item C<$obj> + +is a blessed reference or a string containing a package name + +=item C + +is a package name + +=item C + +is any of the above or an unblessed reference + +=back + +When used as an instance or class method (C<< $obj->isa( TYPE ) >>), +C returns I if $obj is blessed into package C or +inherits from package C. + +When used as a class method (C<< CLASS->isa( TYPE ) >>: sometimes +referred to as a static method), C returns I if C +inherits from (or is itself) the name of the package C or +inherits from package C. When used as a function, like @@ -67,11 +89,15 @@ or require UNIVERSAL ; $yes = UNIVERSAL::isa $a, "ARRAY"; -, C returns I in the same cases as above and also if C is an +C returns I in the same cases as above and also if C is an unblessed reference to a perl variable of type C, such as "HASH", "ARRAY", or "Regexp". -=item $obj->can( METHOD ), CLASS->can( METHOD ), can( VAL, METHOD ) +=item C<< $obj->can( METHOD ) >> + +=item C<< CLASS->can( METHOD ) >> + +=item C C checks if the object or class has a method called C. If it does then a reference to the sub is returned. If it does not then I is @@ -95,24 +121,27 @@ has a method called C, C returns a reference to the subroutine. If C is not a blessed reference, or if it does not have a method C, I is returned. -=item VERSION ( [ REQUIRE ] ) +=item C C will return the value of the variable C<$VERSION> in the package the object is blessed into. If C is given then it will do a comparison and die if the package version is not greater than or equal to C. -C can be called as either a class (static) method, an object method or -or a function. +C can be called as either a class (static) method, an object +method or a function. =back -These subroutines should I be imported via S>. -If you want simple local access to them you can do +=head1 EXPORTS - *isa = \&UNIVERSAL::isa; +None by default. -to import isa into your package. +You may request the import of all three functions (C, C, and +C), however it isn't usually necessary to do so. Perl magically +makes these functions act as methods on all objects. The one exception is +C, which is useful as a function when operating on non-blessed +references. =cut