The R Project SVN R

Rev

Rev 68948 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 68948 Rev 70296
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-2014 R Core Team
3
% Copyright 1995-2016 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<-}
Line 58... Line 58...
58
## creating a multi-expression body
58
## creating a multi-expression body
59
e <- expression(y <- x^2, return(y)) # or a list
59
e <- expression(y <- x^2, return(y)) # or a list
60
body(f) <- as.call(c(as.name("{"), e))
60
body(f) <- as.call(c(as.name("{"), e))
61
f
61
f
62
f(8)
62
f(8)
-
 
63
%% Rd parser bug? : need to backslash-escape the "{" below:
-
 
64
## Using substitute() may be simpler than 'as.call(c(as.name("\{",..)))':
-
 
65
stopifnot(identical(body(f), substitute({ y <- x^2; return(y) })))
63
}
66
}
64
\keyword{programming}
67
\keyword{programming}