EvalFunctionWrapper
classin packageklyn.reflection
public class EvalFunctionWrapper<ReturnType> implements Function<ReturnType>:
EvalFunctionWrapper
All Implemented Interfaces: Function

Internal wrapper for functions created via eval(). Implements Function<R> to provide invoke() and operator call().

import klyn.reflection

f = eval("""def twice(x as Int) as Int:
return x * 2""")
assert f is Invocable<Int>
print(f(21))    # 42
Properties
Modifier and Type Member Description
public readonly property name
name as String:
No summary.
public readonly property parameterCount
parameterCount as Int:
No summary.
public readonly property returnType
returnType as String:
No summary.
Properties inherited from Invocable: name, parameterCount, returnType
Constructors
Modifier and Type Member Description
public EvalFunctionWrapper
EvalFunctionWrapper(name as String, parameterCount as Int, returnTypeName as String, functionPointer as Object):
Creates a typed wrapper over a function produced by `eval()`.
Methods
Modifier and Type Member Description
public invoke
invoke(args as Object[]) as ReturnType throws Exception:
Invokes the function with dynamic arguments.
Methods inherited from Invocable: invoke
Operators
Modifier and Type Member Description
public operator call(args as Object[]) as ReturnType throws Exception: Operator call - enables f(args) syntax.
Operators inherited from Invocable: operator call(args as Object[]) as ReturnType throws Exception