I'll start by saying I don't really understand your remarks about DBM::Deep and tie.

use Object::MultiType; my $scalar = 'abcd'; my $obj = Object::MultiType->new( scalar => $scalar ); print %{$obj} ? 'hash' : 'empty hash', "\n"; __END__ empty hash

Object::MultiType does not die here, so eval would see it the same as everything else. (I had a much longer test set for this, but it doesn't really add anything to what I put in Re^4: Reference assessment techniques and how they fail. Specifically, eval has the side effect of calling overload methods, but blokhead's test doesn't.)

We seem to be talking about a difference between the interface as presented and the interface as implemented. That is, maybe it says it can be a hash, but then it croaks when you try to treat it as one. I think there's a whole range of non-function between total failure and total invulnerability. One side of that range (total failure) is where eval outperforms less invasive checks. The other advantage it seems to have is future-proofing against someday there being another kind of scalar that that acts as a hash but doesn't match the less invasive checks. Are those two advantages bigger than determining type without possibly calling unknown code?

(In case it's not obvious, the subtext of my original article is that determining type—reliably—should be easier than this.)

Looking at the code for Scalar::Util::reftype, I don't see where it reblesses. Its vulnerability seems to be that it relies on the object not to have a particular instance method (a_sub_not_likely_to_be_here), which it has defined in UNIVERSAL. Elsewhere refaddr blesses into 'Scalar::Util::Fake', apparently to keep from calling an overloaded stringifier.


In reply to Re^4: Reference assessment techniques and how they fail by kyle
in thread Reference assessment techniques and how they fail by kyle

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.