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

Internal wrapper for functions created via eval().

The wrapper implements the reflective Invocable<R> contract because the evaluated function's parameter signature is discovered at runtime. Ordinary callbacks should use a structural function type such as (Int) -> Int.

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 ULong
No summary.
public readonly property returnType
returnType as String
No summary.
Constructors
Modifier and Type Member Description
public EvalFunctionWrapper
EvalFunctionWrapper(name as String, parameterCount as ULong, 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.
Operators
Modifier and Type Member Description
public operator ()(args as Object[]) as ReturnType throws Exception Operator call - enables f(args) syntax.