The R Project SVN R

Rev

Rev 70296 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 70296 Rev 78944
Line 1... Line 1...
1
% File src/library/base/man/body.Rd
1
% File src/library/base/man/body.Rd
2
% Part of the R package, https://www.R-project.org
2
% Part of the R package, https://www.R-project.org
3
% Copyright 1995-2016 R Core Team
3
% Copyright 1995-2020 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{body}
6
\name{body}
7
\alias{body}
7
\alias{body}
8
\alias{body<-}
8
\alias{body<-}
9
\title{Access to and Manipulation of the Body of a Function}
9
\title{Access to and Manipulation of the Body of a Function}
10
\description{
10
\description{
11
  Get or set the body of a function.
11
  Get or set the \emph{body} of a function which is basically all of
-
 
12
  the function definition but its formal arguments (\code{\link{formals}}),
-
 
13
  see the \sQuote{Details}.
12
}
14
}
13
\usage{
15
\usage{
14
body(fun = sys.function(sys.parent()))
16
body(fun = sys.function(sys.parent()))
15
body(fun, envir = environment(fun)) <- value
17
body(fun, envir = environment(fun)) <- value
16
}
18
}
Line 31... Line 33...
31
  create such a call.
33
  create such a call.
32
}
34
}
33
\value{
35
\value{
34
  \code{body} returns the body of the function specified.  This is
36
  \code{body} returns the body of the function specified.  This is
35
  normally a \link{language object}, most often a call to \code{\{}, but
37
  normally a \link{language object}, most often a call to \code{\{}, but
36
  it can also be an object (e.g., \code{pi}) to be the return value of
38
  it can also be a \code{\link{symbol}} such as \code{pi} or a constant
37
  the function.
39
  (e.g., \code{3} or \code{"R"}) to be the return value of the function.
38
 
40
 
39
  The replacement form sets the body of a function to the
41
  The replacement form sets the body of a function to the
40
  object on the right hand side, and (potentially) resets the
42
  object on the right hand side, and (potentially) resets the
-
 
43
  \code{\link{environment}} of the function, and drops
41
  environment of the function.  If \code{value} is of class
44
  \code{\link{attributes}}.  If \code{value} is of class
42
  \code{"\link{expression}"} the first element is used as the body:  any
45
  \code{"\link{expression}"} the first element is used as the body:  any
43
  additional elements are ignored, with a warning.
46
  additional elements are ignored, with a warning.
44
}
47
}
45
\seealso{
48
\seealso{
-
 
49
  The three parts of a (non-primitive) function are its
-
 
50
  \code{\link{formals}}, \code{body}, and \code{\link{environment}}.
-
 
51
 
-
 
52
  Further, see
46
  \code{\link{alist}},
53
  \code{\link{alist}},
47
  \code{\link{args}},
54
  \code{\link{args}},
48
  \code{\link{function}}.
55
  \code{\link{function}}.
49
}
56
}
50
\examples{
57
\examples{