summaryrefslogtreecommitdiff
path: root/universal.c
diff options
context:
space:
mode:
authorM.J.T. Guy <mjtg@cus.cam.ac.uk>1997-04-02 01:39:21 +1200
committerTim Bunce <Tim.Bunce@ig.co.uk>1997-08-07 00:00:00 +1200
commite09f3e01ccd721309f0eb0aae224d84db2e8436a (patch)
treeec0d8a22739096439add8120bead7a8811ed74b0 /universal.c
parentd6602a8c317a25957738ed94749408b8c40cda5f (diff)
downloadperl-e09f3e01ccd721309f0eb0aae224d84db2e8436a.tar.gz
UNIVERSAL.pm and import methods (tests)
Hugo van der Sanden <hv@crypt.compulink.co.uk> wrote > I find this form: > > if (ref($from) && > (UNIVERSAL::isa($from,'GLOB') || UNIVERSAL::isa($from,'IO::Handle'))) { > > really ugly. Has it been determined that UNIVERSAL can't simply be fixed in > a way that avoids propagating the import? I agree it's not very pretty. But my feeling is that this is something you don't do very often. The File:: modules are something of a special case, because of all the GLOB vs ref GLOB vs FileHandle vs IO:: stuff. The four examples displayed in my patch really ought to be wrapped up in some central routine, perhaps in IO::Handle. My original message suggested two alternative methods. I think (3) Kludge it is too disgusting to contemplate, but it's easy enough to do. Perhaps someone can suggest a more elegant variant of the theme. I was originally in favour of (4) Hide it, but I've since observed that the PODs are full of suggestions that you can add a method to _all_ classes by defining UNIVERSAL::method. Which pretty much rules out hiding. > I also still feel that $object->isa('UNIVERSAL') should be true for any > blessed reference - I tried asking about this a few times before, but > never received an answer. As it currently stands, it will be true only > if UNIVERSAL has been explicitly added to the package's @ISA, which to > my mind should have no effect at all. How quaint! I can't say I'd noticed that anomaly in my poking about. The attached patch fixes that. It also radically extends the tests for UNIVERSAL. (The new tests assume that my patch to UNIVERSAL.pm has been done.) p5p-msgid: E0whfHh-0007bW-00@ursa.cus.cam.ac.uk
Diffstat (limited to 'universal.c')
-rw-r--r--universal.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/universal.c b/universal.c
index b082da67ff..d6689f8acf 100644
--- a/universal.c
+++ b/universal.c
@@ -71,7 +71,7 @@ int level;
}
}
- return &sv_no;
+ return boolSV(strEQ(name, "UNIVERSAL"));
}
bool