On 2/25/07, Joshua ben Jore <[EMAIL PROTECTED]> wrote:
I've hated it how ref() does the wrong thing so frequently so I wrote
a fix for it. I like to use mock objects to feed fake or proxy objects
to other things but this breaks when things not under my control use
ref() to examine the class of an object.

No longer. Under most circumstances ref() behaves normally. The only
time it lies is if you've requested it from a package and have a ref
method.

I tried adding this bit of code to Exception::NoException last night
and it highlighted the problem that even though I want to have a lying
object, it depends who is asking whether I want to lie or not.

 use UNIVERSAL::ref;
 sub ref { '' }

Exception::NoException is an overloaded object but now overload.pm
doesn't know that anymore and all the overloading breaks. Bummer.
Perhaps I could detect that the object uses overload and therefore it
shouldn't lie to it or perhaps I just declare across the board that
UNIVERSAL::ref doesn't lie to overload or better... I ask you all if
there's a better way to think of this.

overload.pm doesn't say CORE::ref() but that's what it really, truely
intends to say. I can't detect CORE::ref() vs ref() but that doesn't
matter anyway. So... I've got the job of somehow deciding when is an
appropriate time to call the hook or the real ref(). I'm not sure when
that is.

Any thoughts?

Josh

Reply via email to