nuget server logo nuget api documents
↑

API Docs / REnv / DeclareNewFunction

DeclareNewFunction

Full name SMRUCC.Rsharp.Interpreter.ExecuteEngine.ExpressionSymbols.Closure.DeclareNewFunction Assembly REnv Members 17

Function Definition

An R function object. These functions provide the base mechanisms for defining new functions in the R language.

The names in an argument list can be back-quoted non-standard names (see ‘backquote’). If value is missing, NULL is returned. If it is a single expression, the value of the evaluated expression is returned. (The expression is evaluated as soon as return is called, in the evaluation frame of the function and before any on.exit expression is evaluated.) If the end of a function is reached without calling return, the value of the last evaluated expression is returned.

(普通的函数定义模型:

普通的函数与lambda函数DeclareLambdaFunction在结构上是一致的, 但是有一个区别就是lambda函数DeclareLambdaFunction是没有Environment的, 所以lambda函数会更加的轻量化,不容易产生内存溢出的问题)

00 Remarks

This type of function is not the only type in R: they are called closures (a name with origins in LISP) to distinguish them from primitive functions. A closure has three components, its formals (its argument list), its body (expr in the ‘Usage’ section) and its environment which provides the enclosure of the evaluation frame when the closure is used. There is an optional further component if the closure has been byte-compiled. This is not normally user-visible, but it indicated when functions are printed.

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

A subclass of SymbolExpression

01 Syntax

SMRUCC.Rsharp.Interpreter.ExecuteEngine.ExpressionSymbols.Closure.DeclareNewFunction

02 Methods

NameOverloadsSummary
SetSymbol 1 renames current function object its symbol name
getArguments 1 get the parameter arguments of current function object
InitializeEnvironment 1 set parameters
Invoke 1 direct invoke of this R# function
Evaluate 1 just create a new function object in the environment context
ToString 1 Inspect of the function declaration content of current function closure object.
GetSymbolName 1
getReturns 1

03 Properties

NameOverloadsSummary
Namespace 1 这个是当前的这个函数的程序包来源名称,在运行时创建的函数的命令空间为SMRUCC/R#_runtime
type 1
expressionName 1
funcName 1
stackFrame 1
parameters 1
body 1

04 Fields

NameOverloadsSummary
envir 1 The environment of current function closure, this environment context is comes from the environment where this function symbol is created.
hasObjectList 1 does the parameter set of this function contains a ...

05 Members

method SetSymbol #
SetSymbol(String)

renames current function object its symbol name

Parameters
NameTypeDescription
newNameString

-

method getArguments #
getArguments

get the parameter arguments of current function object

Returns

this function will nenver returns nothing

method InitializeEnvironment #
InitializeEnvironment(Environment, InvokeParameter(), Boolean)

set parameters

Parameters
NameTypeDescription
caller_contextEnvironment

The environment context from the caller stack

paramsInvokeParameter()

-

runDisposeBoolean

A byref parameter to indicated that the resulted Environment should be release after this function has been successfully executated?

method Invoke #
Invoke(Object(), Environment)

direct invoke of this R# function

Parameters
NameTypeDescription
argumentsObject()

-

callerEnvironment

-

method Evaluate #
Evaluate(Environment)

just create a new function object in the environment context

Parameters
NameTypeDescription
envirEnvironment

-

method ToString #
ToString

Inspect of the function declaration content of current function closure object.

property Namespace #
Namespace

这个是当前的这个函数的程序包来源名称,在运行时创建的函数的命令空间为SMRUCC/R#_runtime

field envir #
envir

The environment of current function closure, this environment context is comes from the environment where this function symbol is created.

this environment context holder make the closure it works for holding the executation context

field hasObjectList #
hasObjectList

does the parameter set of this function contains a ... object list parameter?

property type #
type
property expressionName #
expressionName
property funcName #
funcName
property stackFrame #
stackFrame
property parameters #
parameters
property body #
body
method GetSymbolName #
GetSymbolName()
method getReturns #
getReturns(Environment)