.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "UNIVERSAL::can 3" .TH UNIVERSAL::can 3 "2020-07-07" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" UNIVERSAL::can \- work around buggy code calling UNIVERSAL::can() as a function .SH "SYNOPSIS" .IX Header "SYNOPSIS" To use this module, simply: .PP .Vb 1 \& use UNIVERSAL::can; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \s-1UNIVERSAL\s0 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. .PP Some authors call methods in the \s-1UNIVERSAL\s0 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. .PP This module replaces \f(CW\*(C`UNIVERSAL::can()\*(C'\fR with a method that checks to see if the first argument is a valid invocant has its own \f(CW\*(C`can()\*(C'\fR method. If so, it gives a warning and calls the overridden method, working around buggy code. Otherwise, everything works as you might expect. .PP Some people argue that you must call \f(CW\*(C`UNIVERSAL::can()\*(C'\fR as a function because you don't know if your proposed invocant is a valid invocant. That's silly. Use \f(CW\*(C`blessed()\*(C'\fR from Scalar::Util if you want to check that the potential invocant is an object or call the method anyway in an \f(CW\*(C`eval\*(C'\fR block and check for failure (though check the exception \fIreturned\fR, as a poorly-written \&\f(CW\*(C`can()\*(C'\fR method could break Liskov and throw an exception other than \*(L"You can't call a method on this type of invocant\*(R"). .PP Just don't break working code. .SH "AUTHOR" .IX Header "AUTHOR" chromatic, \f(CW\*(C`\*(C'\fR .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests to \f(CW\*(C`bug\-universal\-can@rt.cpan.org\*(C'\fR, or through the web interface at . 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. .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" Inspired by UNIVERSAL::isa by Yuval Kogman, Autrijus Tang, and myself. .PP Adam Kennedy has tirelessly made me tired by reporting potential bugs and suggesting ideas that found actual bugs. .PP Mark Clements helped to track down an invalid invocant bug. .PP Curtis \*(L"Ovid\*(R" Poe finally provided the inspiration I needed to clean up the interface. .PP Peter du Marchie van Voorthuysen identified and fixed a problem with calling \&\f(CW\*(C`SUPER::can\*(C'\fR. .PP Daniel LeWarne found and fixed a deep recursion error. .PP Norbert Buchmüller fixed an overloading bug in blessed invocants. .PP The Perl \s-1QA\s0 list had a huge... discussion... which inspired my realization that this module needed to do what it does now. .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright (c) 2005 \- 2014, chromatic. This module is made available under the same terms as Perl 5.12.