1UNIVERSAL::can(3)     User Contributed Perl Documentation    UNIVERSAL::can(3)
2
3
4

NAME

6       UNIVERSAL::can - Hack around people calling UNIVERSAL::can() as a
7       function
8

VERSION

10       Version 1.14
11

SYNOPSIS

13       To use this module, simply:
14
15         use UNIVERSAL::can;
16

DESCRIPTION

18       The UNIVERSAL class provides a few default methods so that all objects
19       can use them.  Object orientation allows programmers to override these
20       methods in subclasses to provide more specific and appropriate
21       behavior.
22
23       Some authors call methods in the UNIVERSAL class on potential invocants
24       as functions, bypassing any possible overriding.  This is wrong and you
25       should not do it.  Unfortunately, not everyone heeds this warning and
26       their bad code can break your good code.
27
28       This module replaces "UNIVERSAL::can()" with a method that checks to
29       see if the first argument is a valid invocant has its own "can()"
30       method.  If so, it gives a warning and calls the overridden method,
31       working around buggy code.  Otherwise, everything works as you might
32       expect.
33
34       Some people argue that you must call "UNIVERSAL::can()" as a function
35       because you don't know if your proposed invocant is a valid invocant.
36       That's silly.  Use "blessed()" from Scalar::Util if you want to check
37       that the potential invocant is an object or call the method anyway in
38       an "eval" block and check for failure (though check the exception
39       returned, as a poorly-written "can()" method could break Liskov and
40       throw an exception other than "You can't call a method on this type of
41       invocant").
42
43       Just don't break working code.
44

AUTHOR

46       chromatic, "<chromatic@wgz.org>"
47

BUGS

49       Please report any bugs or feature requests to
50       "bug-universal-can@rt.cpan.org", or through the web interface at
51       http://rt.cpan.org/NoAuth/ReportBug.html?Queue=UNIVERSAL-can
52       <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=UNIVERSAL-can>.  This
53       will contact me, hold onto patches so I don't drop them, and will
54       notify you of progress on your request as I make changes.
55

ACKNOWLEDGEMENTS

57       Inspired by UNIVERSAL::isa by Yuval Kogman, Autrijus Tang, and myself.
58
59       Adam Kennedy has tirelessly made me tired by reporting potential bugs
60       and suggesting ideas that found actual bugs.
61
62       Mark Clements helped to track down an invalid invocant bug.
63
64       Curtis "Ovid" Poe finally provided the inspiration I needed to clean up
65       the interface.
66
67       Peter du Marchie van Voorthuysen identified and fixed a problem with
68       calling "SUPER::can".
69
70       The Perl QA list had a huge... discussion... which inspired my
71       realization that this module needed to do what it does now.
72
74       Artistic License 2.0, copyright (c) 2005 - 2009 chromatic. Some rights
75       reserved.
76
77
78
79perl v5.12.0                      2010-05-07                 UNIVERSAL::can(3)
Impressum