Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

TheNomad (7014)

TheNomad
  (email not shown publicly)

Journal of TheNomad (7014)

Tuesday September 30, 2008
05:03 PM

Is Object::InsideOut broken?

[ #37579 ]

Or is it Test::MockObject? Or UNIVERSAL::can that's broken?

This is something that has been exercising my mind recently, and I've decided that it's Object::InsideOut. (Yeah, go on flame me!).

If you use both Test::MockObject and Object::InsideOut in your project, you'll find you get lots of 'UNIVERSAL::can called as function not as method' warnings.

These warnings are generated by UNIVERSAL::can, which is pulled in by Test::MockObject.

Object::InsideOut grabs a code ref to UNIVERSAL::can:

$GBL{'can'} = \&UNIVERSAL::can

and then calls it:

$code = $$GBL{'can'}->($thing, $method);

Naturally, a warning ensues. I've managed to suppress the warning using the modules in this order at the head of the script:

use Object::InsideOut (); use UNIVERSAL::isa;

I just wish these two modules would play together nicely.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • UNIVERSAL::can() is a method. Calling methods as if they were functions does not work reliably. O::IO's use of the function reference is a bug.

  • If you're using Object::InsideOut, Test::MockObject, and UNIVERSAL::isa, you've just stepped into the middle of several vicious pedant wars (Google should turn up some goodies). I would suggest not using one or more of these modules.

    • Well, that's an easy decision. I'd stop using Object::InsideOut on the basis that inside-out objects are a fad.

      The thing is to file a a bug report on OIO, but I can't straight away see how to fix the problem.

      • After skimming the code, I wonder if OIO could stop monkeysquatting UNIVERSAL::isa and UNIVERSAL::can, perhaps by installing its own methods as methods in OIO-created classes (unless they already exist).

  • Despite being better than it was, UNIVERSAL::isa/can still aren't suitably complete.

    Last time I checked, I think they still didn't support re-entrancy.

    That is, if you have a custom ->isa that itself calls another ->isa, the second one doesn't work properly.

    • Last time I checked, I think they still didn't support re-entrancy.

      I fixed those bugs per your test cases last year sometime. I'm sure I asked if you could reproduce any problems in the ticket.

  • With thanks to TheNomad's for his prodding me on this issue, I have "fixed" OIO to have "proper" implementations for ->can() and ->isa() that do not rely on cached references to UNIVERSAL::can() and UNIVERSAL::isa().

    With this reimplementation, OIO should now play well with Test::MockObject and the chromatic's CPAN versions of UNIVERSAL::can and UNIVERSAL::isa, and, hopefully, should eliminate the possibility of further conflicts of this nature.