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>.  This
52       will contact me, hold onto patches so I don't drop them, and will
53       notify you of progress on your request as I make changes.
54

ACKNOWLEDGEMENTS

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