/
callGeneric.html
121 lines (85 loc) · 3.21 KB
/
callGeneric.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>R: Call the Current Generic Function from a Method</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="R.css">
</head><body>
<table width="100%" summary="page for callGeneric"><tr><td>callGeneric</td><td align="right">R Documentation</td></tr></table>
<h2>Call the Current Generic Function from a Method</h2>
<h3>Description</h3>
<p>A call to <code>callGeneric</code> can only appear inside a method
definition. It then results in a call to the current generic
function. The value of that call is the value of <code>callGeneric</code>.
While it can be called from any method, it is useful and typically
used in methods for group generic functions.
</p>
<h3>Usage</h3>
<pre>
callGeneric(...)
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>...</code></td>
<td>
<p>Optionally, the arguments to the function in its next call.
</p>
<p>If no arguments are included in the call to <code>callGeneric</code>, the
effect is to call the function with the current arguments.
See the detailed description for what this really means.
</p>
</td></tr>
</table>
<h3>Details</h3>
<p>The name and package of the current generic function is stored in the
environment of the method definition object. This name is looked up
and the corresponding function called.
</p>
<p>The statement that passing no arguments to <code>callGeneric</code> causes
the generic function to be called with the current arguments is
more precisely as follows. Arguments that were missing in the current
call are still missing (remember that <code>"missing"</code> is a valid
class in a method signature). For a formal argument, say <code>x</code>, that
appears in the original call, there is a corresponding argument in the
generated call equivalent to <code>x = x</code>. In effect, this
means that the generic function sees the same actual arguments, but
arguments are evaluated only once.
</p>
<p>Using <code>callGeneric</code> with no arguments is prone to creating
infinite recursion, unless one of the arguments in the signature has
been modified in the current method so that a different method is selected.
</p>
<h3>Value</h3>
<p>The value returned by the new call.
</p>
<h3>References</h3>
<p>Chambers, John M. (2008)
<EM>Software for Data Analysis: Programming with R</EM>
Springer. (For the R version.)
</p>
<p>Chambers, John M. (1998)
<EM>Programming with Data</EM>
Springer (For the original S4 version.)
</p>
<h3>See Also</h3>
<p><code>GroupGenericFunctions</code> for other information
about group generic functions; Methods for the general behavior
of method dispatch
</p>
<h3>Examples</h3>
<pre>
## the method for group generic function Ops
## for signature( e1="structure", e2="vector")
function (e1, e2)
{
value <- callGeneric(e1@.Data, e2)
if (length(value) == length(e1)) {
e1@.Data <- value
e1
}
else value
}
## For more examples
## Not run:
showMethods("Ops", includeDefs = TRUE)
## End(Not run)
</pre>
</body></html>