On Fri, 7 Apr 2006, demerphq wrote:
On 4/7/06, Adam Kennedy <[EMAIL PROTECTED]> wrote:
Just because I (repeatedly) attack chromatic over UNIVERSAL::isa/can
nobody should be under the impression that using the functions directly
is in any way a good thing.
The only cases for which it's genuinely useful is asking "ignoring what
you say you are in OO terms, what are you actually implemented as
underneath".
The only advantage I can think of using the function form of isa/can
is that you dont have to do a ref test first. Or if you want to find
out if a module is lying to you about what it isa/can do. But its not
actually that useful to find out how the module is implemented
underneath, nor is that useful for finding out how an object can be
used/dereferenced.
Your $thingy could be a hashref, in which case $thingy->isa will die.
I've been using it a lot recently to catch exceptions. What's so wrong
with the below, almost identical to the example in perldoc -f die? I'd
rather not die again immediately by assuming [EMAIL PROTECTED]>isa will work.
eval {
# do some stuff
};
if ( $@ ) {
if( UNIVERSAL::isa($@, 'My::Exception') ) {
# known exception, handle appropriately
}
else {
die "Ooops-a-daisy: $@";
}
}
--
david