| 42333 |
ripley |
1 |
% File src/library/methods/man/method.skeleton.Rd
|
| 68948 |
ripley |
2 |
% Part of the R package, https://www.R-project.org
|
| 71228 |
maechler |
3 |
% Copyright 1995-2016 R Core Team
|
| 42333 |
ripley |
4 |
% Distributed under GPL 2 or later
|
|
|
5 |
|
| 40918 |
jmc |
6 |
\name{method.skeleton}
|
| 56186 |
murdoch |
7 |
\alias{method.skeleton}
|
| 40918 |
jmc |
8 |
\title{Create a Skeleton File for a New Method}
|
|
|
9 |
\description{
|
| 43745 |
maechler |
10 |
This function writes a source file containing a call to
|
|
|
11 |
\code{\link{setMethod}} to define a method for the generic function
|
|
|
12 |
and signature supplied. By default the method definition is in line
|
|
|
13 |
in the call, but can be made an external (previously assigned) function.
|
| 40918 |
jmc |
14 |
}
|
|
|
15 |
\usage{
|
| 42421 |
jmc |
16 |
method.skeleton(generic, signature, file, external = FALSE, where)
|
| 40918 |
jmc |
17 |
}
|
|
|
18 |
\arguments{
|
|
|
19 |
\item{generic}{the character string name of the generic function, or
|
|
|
20 |
the generic function itself. In the first case, the function
|
|
|
21 |
need not currently be a generic, as it would not for the
|
|
|
22 |
resulting call to \code{\link{setMethod}}.}
|
|
|
23 |
\item{signature}{the method signature, as it would be given to \code{\link{setMethod}}}
|
|
|
24 |
\item{file}{a character string name for the output file, or a
|
|
|
25 |
writable connection. By default the generic function name and
|
|
|
26 |
the classes in the signature are concatenated, with separating
|
|
|
27 |
underscore characters. The file name should normally end in \code{".R"}. }
|
|
|
28 |
|
|
|
29 |
To write multiple method skeletons to one file, open the file
|
|
|
30 |
connection first and then pass it to \code{method.skeleton()} in
|
|
|
31 |
multiple calls.
|
|
|
32 |
\item{external}{flag to control whether the function definition for
|
|
|
33 |
the method should be a separate external object assigned in the
|
|
|
34 |
source file, or included in line in the call to
|
|
|
35 |
\code{\link{setMethod}}.
|
|
|
36 |
If supplied as a character string, this will be used as the name
|
|
|
37 |
for the external function; by default the name concatenates the
|
| 42421 |
jmc |
38 |
generic and signature names, with separating underscores.}
|
|
|
39 |
\item{where}{The environment in which to look for the function; by default,
|
|
|
40 |
the top-level environment of the call to \code{method.skeleton}.}
|
| 40918 |
jmc |
41 |
}
|
|
|
42 |
\value{
|
|
|
43 |
The \code{file} argument, invisibly, but the function is used for its side effect.
|
|
|
44 |
}
|
| 43745 |
maechler |
45 |
\seealso{\code{\link{setMethod}}, \code{\link{package.skeleton}}
|
|
|
46 |
}
|
| 40918 |
jmc |
47 |
\examples{
|
| 43745 |
maechler |
48 |
\dontshow{oWD <- setwd(tempdir())}
|
| 71228 |
maechler |
49 |
setClass("track", slots = c(x ="numeric", y="numeric"))
|
| 43745 |
maechler |
50 |
method.skeleton("show", "track") ## writes show_track.R
|
|
|
51 |
method.skeleton("Ops", c("track", "track")) ## writes "Ops_track_track.R"
|
|
|
52 |
|
| 40918 |
jmc |
53 |
## write multiple method skeletons to one file
|
| 43745 |
maechler |
54 |
con <- file("./Math_track.R", "w")
|
| 40918 |
jmc |
55 |
method.skeleton("Math", "track", con)
|
|
|
56 |
method.skeleton("exp", "track", con)
|
|
|
57 |
method.skeleton("log", "track", con)
|
|
|
58 |
close(con)
|
| 43745 |
maechler |
59 |
\dontshow{setwd(oWD)}
|
| 40918 |
jmc |
60 |
}
|
|
|
61 |
\keyword{programming}
|
|
|
62 |
\keyword{methods}
|