From: Gisle Aas Date: Fri, 14 Feb 1997 15:52:21 +0000 (+0000) Subject: Remove redundant functions UNIVERSAL::{class,is_instance} X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=77bb9b23081b62119e8fbe9f5655b8802e4537ae;p=p5sagit%2Fp5-mst-13.2.git Remove redundant functions UNIVERSAL::{class,is_instance} Nick Ing-Simmons writes: > Loose them! p5p-msgid: --- diff --git a/pod/perldelta.pod b/pod/perldelta.pod index bfaeedc..df18462 100644 --- a/pod/perldelta.pod +++ b/pod/perldelta.pod @@ -277,34 +277,6 @@ C form of C. # implies: A->VERSION(1.2); -=item class() - -C returns the class name of its object. - -=item is_instance() - -C returns true if its object is an instance of some -class, false if its object is the class (package) itself. Example - - A->is_instance(); # False - - $var = 'A'; - $var->is_instance(); # False - - $ref = bless [], 'A'; - $ref->is_instance(); # True - -This can be useful for methods that wish to easily distinguish -whether they were invoked as class or as instance methods. - - sub some_meth { - my $classname = shift; - if ($classname->is_instance()) { - die "unexpectedly called as instance not class method"; - } - ..... - } - =back B C directly uses Perl's internal code for method lookup, and diff --git a/pod/perlobj.pod b/pod/perlobj.pod index 9b1ede1..c8b85b4 100644 --- a/pod/perlobj.pod +++ b/pod/perlobj.pod @@ -313,23 +313,6 @@ C form of C. # implies: A->VERSION(1.2); -=item class() - -C returns the class name of its object. - -=item is_instance() - -C returns true if its object is an instance of some -class, false if its object is the class (package) itself. Example - - A->is_instance(); # False - - $var = 'A'; - $var->is_instance(); # False - - $ref = bless [], 'A'; - $ref->is_instance(); # True - =back B C directly uses Perl's internal code for method lookup, and diff --git a/universal.c b/universal.c index 74d182d..03b907d 100644 --- a/universal.c +++ b/universal.c @@ -170,26 +170,6 @@ XS(XS_UNIVERSAL_can) } static -XS(XS_UNIVERSAL_is_instance) -{ - dXSARGS; - ST(0) = SvROK(ST(0)) ? &sv_yes : &sv_no; - XSRETURN(1); -} - -static -XS(XS_UNIVERSAL_class) -{ - dXSARGS; - if(SvROK(ST(0)) && SvOBJECT(SvRV(ST(0)))) { - SV *sv = sv_newmortal(); - sv_setpv(sv, HvNAME(SvSTASH(SvRV(ST(0))))); - ST(0) = sv; - } - XSRETURN(1); -} - -static XS(XS_UNIVERSAL_VERSION) { dXSARGS; @@ -239,7 +219,5 @@ boot_core_UNIVERSAL() newXS("UNIVERSAL::isa", XS_UNIVERSAL_isa, file); newXS("UNIVERSAL::can", XS_UNIVERSAL_can, file); - newXS("UNIVERSAL::class", XS_UNIVERSAL_class, file); - newXS("UNIVERSAL::is_instance", XS_UNIVERSAL_is_instance, file); newXS("UNIVERSAL::VERSION", XS_UNIVERSAL_VERSION, file); }