more useful options | |
PerlMonks |
Re^4: Is "ref($class) || $class" a bad thing?by stvn (Monsignor) |
on Jul 13, 2004 at 01:11 UTC ( [id://373790]=note: print w/replies, xml ) | Need Help?? |
Seems like it'd be less work to write: As dragonchild already pointed out, this would not handle Foo::new({}), nor would it handle Foo::new("Data::Dumper"). Both are things are equally as stupid for a user to do, but a new user may not realize the method/function difference, the real question is whether that is my reponsibility or not. If you really want to be paranoid, though, you should make something similar a precondition of all of your methods. I assume you mean to check $self, that is true, but even I think that would a little much. Also, you ought to call isa() directly, not through UNIVERSAL::, in case someone overrides it. That too would not work for Foo::new({}) or other such insanity. I am really just trying to find something in between totally over-the-top paranoid, and you-break-it-you-buy-it-an-I-dont-care. And I am still looking as I think the example I gave above it probably too much.
-stvn
In Section
Meditations
|
|