in reply to Re^3: I don't understand UNIVERSAL::DOES()
in thread I don't understand UNIVERSAL::DOES()
why not fix the real problem and allow methods on all references via autobox?
Well, that would address /one/ of my concerns, that is it would not just die on an unblessed reference. But it doesnt address the other issues I mentioned.
UNIVERSAL::DOES() is a perfect opportunity to address a host of typing related issues in Perl in one routine without burdening ourselves with yet another partial solution. Currently we have (at least) ref, Scalar::Util::reftype, Scalar::Util::blessed, UNIVERSAL::isa, overload::Method, and re::is_regexp(). Thats a lot of routines to know about, and to know how to use in concert properly. UNIVERSAL::DOES() seems like the perfect place to roll them all together into something sensible.
Also it seems to me that DOES is the /correct/ place to ask "can I use $x as a subroutine reference", and not barf because $x is not UNIVERSAL::ISA($x,'CODE') but rather a blessed array reference that happens to overload code deferencing. DOES is about what one can use an object for after all.
If we can get a sensible routine into core then people will use it, but if its another 2/3rds solution as so many of the existing routines are I bet it wont get used much at all. And will be in my eyes at least a missed opportunity. Especially as by writing it in C the code can be /much/ faster and accurate than any roll your own type detection code is.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: I don't understand UNIVERSAL::DOES()
by chromatic (Archbishop) on Mar 09, 2007 at 21:52 UTC | |
by demerphq (Chancellor) on Mar 10, 2007 at 10:25 UTC | |
by chromatic (Archbishop) on Mar 10, 2007 at 20:05 UTC | |
by demerphq (Chancellor) on Mar 11, 2007 at 09:14 UTC | |
|
Re^5: I don't understand UNIVERSAL::DOES()
by ikegami (Patriarch) on Mar 09, 2007 at 21:16 UTC | |
by tye (Sage) on Mar 09, 2007 at 21:27 UTC | |
by ikegami (Patriarch) on Mar 12, 2007 at 08:24 UTC |