in reply to Re^5: I don't understand UNIVERSAL::DOES()
in thread I don't understand UNIVERSAL::DOES()

*isa= \&UNIVERSAL::isa;

works great for me. I don't even have to "use UNIVERSAL" for this. There being no UNIVERSAL->import() makes some sense to me, but, as noted in Universally unimportant and overused, UNIVERSAL->import() appears to exist (and causes problems).

Defining a special UNIVERSAL::isa() that can detect when it has been misused would be an acceptable compromise to me.

- tye        

Replies are listed 'Best First'.
Re^7: I don't understand UNIVERSAL::DOES() (import)
by ikegami (Patriarch) on Mar 12, 2007 at 08:24 UTC

    The last paragraph was the most important, and it wasn't addressed. My fault, I didn't explain myself. Consider

    { package Foo; sub DOES { my ($self, $role) = @_; return 1 if ...; return $self->SUPER::DOES($role); } } Foo->DOES(...); # Line "A" UNIVERSAL::DOES('Foo', ...); # Line "B"

    Unless DOES does something non-intuitive, line "A" results in an infinite loop.
    Unless DOES does something non-intuitive, line "B" doesn't call the overridden DOES.

    Do we really want DOES to be that special? Having a function does (which calls DOES when appropriate) would avoid all this complexity.