DeclareNewFunction {SMRUCC.Rsharp.Interpreter.ExecuteEngine.ExpressionSymbols.Closure} .NET clr documentation

DeclareNewFunction

Description

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函数会更加的轻量化,不容易产生内存溢出的问题)

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

Declare

            
# namespace SMRUCC.Rsharp.Interpreter.ExecuteEngine.ExpressionSymbols.Closure
export class DeclareNewFunction extends SymbolExpression {
   body: ClosureExpression;
   expressionName: ExpressionTypes;
   funcName: string;
   isCallable: boolean;
   # 这个是当前的这个函数的程序包来源名称,在运行时创建的函数的命令空间为SMRUCC/R#_runtime
   Namespace: string;
   parameters: DeclareNewSymbol[];
   stackFrame: StackFrame;
   type: TypeCodes;
}

        

.NET clr type reference tree

  1. this class extends from SymbolExpression class: SymbolExpression
  2. use by property member body: ClosureExpression
  3. use by property member expressionName: ExpressionTypes
  4. use by property member parameters: DeclareNewSymbol
  5. use by property member stackFrame: StackFrame
  6. use by property member type: TypeCodes

[Package {$package} version {$version} Index]