The R Project SVN R

Rev

Rev 71420 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
71366 jmc 1
% File src/library/methods/man/setGeneric.Rd
2
% Part of the R package, https://www.R-project.org
71420 maechler 3
% Copyright 1995-2016 R Core Team
71366 jmc 4
% Distributed under GPL 2 or later
5
 
6
\name{setGroupGeneric}
7
\alias{setGroupGeneric}
8
\title{Create a Group Generic Version of a Function}
9
\description{
10
 
11
  The \code{setGroupGeneric} function behaves like \code{\link{setGeneric}}
12
  except that it constructs a group generic function, differing in two
13
  ways from an ordinary generic function.  First, this function cannot
14
  be called directly, and the body of the function created will contain
15
  a stop call with this information.  Second, the group generic function
16
  contains information about the known members of the group, used to
17
  keep the members up to date when the group definition changes, through
18
  changes in the search list or direct specification of methods, etc.
19
 
20
  All members of the group must have the identical argument list.
21
}
22
\usage{
23
setGroupGeneric(name, def= , group=list(), valueClass=character(),
24
                knownMembers=list(), package= , where= )
25
}
26
\arguments{
71420 maechler 27
  \item{name}{the character string name of the generic function.
28
   }
71366 jmc 29
  \item{def}{A function object.  There isn't likely to be an existing
71420 maechler 30
    nongeneric of this name, so some function needs to be supplied.  Any
31
    known member or other function with the same argument list will do,
32
    because the group generic cannot be called directly.
71366 jmc 33
  }
71420 maechler 34
  \item{group, valueClass}{arguments to pass to
35
    \code{\link{setGeneric}}.
71366 jmc 36
  }
71420 maechler 37
  \item{knownMembers}{the names of functions that are
71366 jmc 38
    known to be members of this group.  This information is used to
39
    reset cached definitions of the member generics when information
40
    about the group generic is changed.
41
  }
71420 maechler 42
  \item{package, where}{passed to \code{\link{setGeneric}}, but
43
    obsolete and to be avoided.}
71366 jmc 44
}
45
\value{
46
  The \code{setGroupGeneric} function exists for its side effect: saving the
47
  generic function to allow methods to be specified later.  It returns
48
  \code{name}.
49
}
50
\references{
88585 hornik 51
  \bibshow{R:Chambers:2016}
71366 jmc 52
}
53
\examples{
54
\dontrun{
55
## the definition of the "Logic" group generic in the methods package
56
setGroupGeneric("Logic", function(e1, e2) NULL,
57
    knownMembers = c("&", "|"))
58
}
59
}
60
 
61
\seealso{
62
  \code{\link{Methods_Details}} and the links there for a general discussion,
63
  \code{\link{dotsMethods}} for methods that dispatch on
64
  \code{\dots}, and \code{\link{setMethod}} for method definitions.
65
}
66
\keyword{ programming }
67
\keyword{ methods }