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 Int:
No summary.
public readonly property returnType
returnType as String:
No summary.
Inherited Properties
propertyInherited Properties 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.
Inherited Methods
methodInherited Methods 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.
Inherited Operators
operatorInherited Operators from Invocable: operator call(args as Object[]) as ReturnType throws Exception