Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: isa() on any scalar

by gam3 (Curate)
on Jun 11, 2005 at 02:15 UTC ( [id://465738]=note: print w/replies, xml ) Need Help??


in reply to Re^2: isa() on any scalar
in thread isa() on any scalar

No don't do this either. An exception should only be used to catch exceptional events. Since it seems that $value is just as likely not to be a 'Node' as it is to be one you should not use an exception to test it.
-- gam3
A picture is worth a thousand words, but takes 200K.

Replies are listed 'Best First'.
Re^4: isa() on any scalar
by chromatic (Archbishop) on Jun 11, 2005 at 08:35 UTC

    As I mentioned, if $value is not a valid invocant, it is an exceptional case.

    I'm not aware of any other idiom that respects potentially-overridden isa() methods and handles potentially invalid invocants in one statement. If you know one, please share.

    Scalar::Util's blessed() is pretty good, but that technique disallows calling isa() as a class method. Sometimes that's good. Sometimes it's not.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://465738]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2024-03-28 16:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found