The R Project SVN R

Rev

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

Rev 75377 Rev 79553
Line 1... Line 1...
1
% File src/library/base/man/function.Rd
1
% File src/library/base/man/function.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-2012 R Core Team
3
% Copyright 1995-2021 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{function}
6
\name{function}
7
\alias{function}
7
\alias{function}
8
\alias{return}
8
\alias{return}
9
\alias{closure}
9
\alias{closure}
10
 
10
 
11
\title{Function Definition}
11
\title{Function Definition}
12
\usage{
12
\usage{
13
\special{function( arglist ) expr}
13
\special{function( arglist ) expr}
-
 
14
\special{\\( arglist ) expr}
14
\special{return(value)}
15
\special{return(value)}
15
}
16
}
16
\description{
17
\description{
17
  These functions provide the base mechanisms for defining
18
  These functions provide the base mechanisms for defining
18
  new functions in the \R language.
19
  new functions in the \R language.
Line 32... Line 33...
32
  the evaluation frame of the function and before any
33
  the evaluation frame of the function and before any
33
  \code{\link{on.exit}} expression is evaluated.)
34
  \code{\link{on.exit}} expression is evaluated.)
34
 
35
 
35
  If the end of a function is reached without calling \code{return}, the
36
  If the end of a function is reached without calling \code{return}, the
36
  value of the last evaluated expression is returned.
37
  value of the last evaluated expression is returned.
-
 
38
 
-
 
39
  The shorthand form \code{\\(x) x + 1} is parsed as \code{function(x) x
-
 
40
    + 1}. It may be helpful in making code containing simple function
-
 
41
  expressions more readable.
37
}
42
}
-
 
43
\note{ \bold{The shorthand function notation is experimental and may change
-
 
44
    prior to release.} }
38
 
45
 
39
\section{Technical details}{
46
\section{Technical details}{
40
  This type of function is not the only type in \R: they are called
47
  This type of function is not the only type in \R: they are called
41
  \emph{closures} (a name with origins in LISP) to distinguish them from
48
  \emph{closures} (a name with origins in LISP) to distinguish them from
42
  \link{primitive} functions.
49
  \link{primitive} functions.