My main problem with it is isn't so much the wording, but the fact that it doesn't even say which argument caused the problem.

Sure it does. the message says

Can't call method "isa" on unblessed reference at unblessedWantBetterError.t line 10.

Which tells us that on line 10 some $var is being used as an object in a method call and the content of $var is not actually an object. When we look at line 10 we see

die "not a foo" unless $obj->isa('foo'); #the error I want

which tells us that the $var in question is called $obj.

Now presumably you are doing this because later on you have code that does something like

$obj->do_something($useful);

But what do you gain? In this situation you would see the same error you are now just on the actual line where the actual code is being used, and not on some validation code.

So IMO you gain nothing but code complexity and you tie the hands of your codes consumers because they can't drop in a different object with a compatible interface. So IOW, you have made your code less usable and robust than more.

---
$world=~s/war/peace/g


In reply to Re^3: How to differentiate hash reference and object reference? by demerphq
in thread How to differentiate hash reference and object reference? by tphyahoo

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.