Query: universal::can
OS: debian
Section: 3pm
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
UNIVERSAL::can(3pm) User Contributed Perl Documentation UNIVERSAL::can(3pm)NAMEUNIVERSAL::can - work around buggy code calling UNIVERSAL::can() as a functionSYNOPSISTo use this module, simply: use UNIVERSAL::can;DESCRIPTIONThe UNIVERSAL class provides a few default methods so that all objects can use them. Object orientation allows programmers to override these methods in subclasses to provide more specific and appropriate behavior. Some authors call methods in the UNIVERSAL class on potential invocants as functions, bypassing any possible overriding. This is wrong and you should not do it. Unfortunately, not everyone heeds this warning and their bad code can break your good code. This module replaces "UNIVERSAL::can()" with a method that checks to see if the first argument is a valid invocant has its own "can()" method. If so, it gives a warning and calls the overridden method, working around buggy code. Otherwise, everything works as you might expect. Some people argue that you must call "UNIVERSAL::can()" as a function because you don't know if your proposed invocant is a valid invocant. That's silly. Use "blessed()" from Scalar::Util if you want to check that the potential invocant is an object or call the method anyway in an "eval" block and check for failure (though check the exception returned, as a poorly-written "can()" method could break Liskov and throw an exception other than "You can't call a method on this type of invocant"). Just don't break working code.AUTHORchromatic, "<chromatic@wgz.org>"BUGSPlease report any bugs or feature requests to "bug-universal-can@rt.cpan.org", or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=UNIVERSAL-can <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=UNIVERSAL-can>. This will contact me, hold onto patches so I don't drop them, and will notify you of progress on your request as I make changes.ACKNOWLEDGEMENTSInspired by UNIVERSAL::isa by Yuval Kogman, Autrijus Tang, and myself. Adam Kennedy has tirelessly made me tired by reporting potential bugs and suggesting ideas that found actual bugs. Mark Clements helped to track down an invalid invocant bug. Curtis "Ovid" Poe finally provided the inspiration I needed to clean up the interface. Peter du Marchie van Voorthuysen identified and fixed a problem with calling "SUPER::can". Daniel LeWarne found and fixed a deep recursion error. Norbert BuchmA~Xller fixed an overloading bug in blessed invocants. The Perl QA list had a huge... discussion... which inspired my realization that this module needed to do what it does now. COPYRIGHT & LICENSE Artistic License 2.0, copyright (c) 2005 - 2011 chromatic. Some rights reserved. perl v5.12.3 2011-06-13 UNIVERSAL::can(3pm)
Related Man Pages |
---|
universal(3pm) - redhat |
universal(3pm) - suse |
universal::require5.18(3) - mojave |
universal::can(3pm) - debian |
universal::require(3pm) - debian |
Similar Topics in the Unix Linux Community |
---|
Installing Dash Shell on OS X Lion |
How can I do this in VI editor? |
Find columns in a file based on header and print to new file |
New UNIX and Linux History Sections |