1Callback(3)           User Contributed Perl Documentation          Callback(3)
2
3
4

NAME

6       Callback - object interface for function callbacks
7

SYNOPSIS

9               use Callback;
10
11               my $callback = new Callback (\&myfunc, @myargs);
12               my $callback = new Callback ($myobj, $mymethod, @myargs);
13               my $callback = new Callback ($old_callback, @myargs);
14
15               $callback->call(@some_more_args);
16

DESCRIPTION

18       Callback provides a standard interface to register callbacks.  Those
19       callbacks can be either purely functional (i.e. a function call with
20       arguments) or object-oriented (a method call on an object).
21
22       When a callback is constructed, a base set of arguments can be
23       provided.  These function arguments will preceed any arguments added at
24       the time the call is made.
25
26       There are two forms for the callback constructor, depending on whether
27       the call is a pure functional call or a method call.  The rule is that
28       if the first argument is an object, then the second argument is a
29       method name to be called on that object.  Method resolution happens at
30       the time the Callback object is built: an error will be raised if it
31       cannot be found.
32
33       Callback objects built for object-oriented calls also have the property
34       of being serializable via Storable.  Purely functional callabacks
35       cannot be serialized because CODE references are not supported by
36       Storable.
37
38       Callback objects can be created from existing Callback objects.  Any
39       arguments will be appended onto the original list of arguments.
40

TRACING

42               use Callback qw(@callbackTrace);
43
44       If you're writing a debugging routine that provides a stack-dump (for
45       example, Carp::confess) it is useful to know where a callback was
46       registered.
47
48               my $ct = 0;
49               while (($package, $file, $line, $subname, $hasargs, $wantarray) = caller($i++)) {
50                   ...
51
52                   if ($subname eq 'Callback::call') {
53                       print "callback registered $Callback::callbackTrace[$ct]\n";
54                       $ct++;
55                   }
56               }
57
58       Without such code, it becomes very hard to know what's going on.
59
61       Copyright (C) 1994, 2000, 2002 David Muir Sharnoff.   All rights
62       reserved.  This module may be licensed on the same terms as Perl
63       itself.
64

AUTHORS

66       David Muir Sharnoff <muir@idiom.com> and Raphael Manfredi
67       <Raphael_Manfredi@pobox.com>
68

SEE ALSO

70       Storable(3).
71
72
73
74perl v5.34.0                      2021-07-22                       Callback(3)
Impressum