Package team.unnamed.mocha.runtime.value
Interface Function<T>
- All Superinterfaces:
Value
- All Known Implementing Classes:
JavaFunction
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Represents a Molang function. Receives a certain amount of
parameters and (optionally) returns a value. Can be called
from Molang code using call expressions:
my_function(1, 2, 3)
This is a very low-level function that is "expression-sensitive", this means, it takes the raw expression arguments instead of the evaluated expression argument values.
- Since:
- 3.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceRepresents aFunctionargument.static interfaceRepresents a collection ofFunctionFunction.Arguments. -
Method Summary
Modifier and TypeMethodDescriptiondefault @Nullable Valueevaluate(@NotNull ExecutionContext<T> context) Executes this function.@Nullable Valueevaluate(@NotNull ExecutionContext<T> context, @NotNull Function.Arguments arguments) Executes this function with the given arguments.default booleanpure()Determines if this function is pure or not.Methods inherited from interface team.unnamed.mocha.runtime.value.Value
getAsBoolean, getAsNumber, getAsString, isString
-
Method Details
-
evaluate
@Nullable @Nullable Value evaluate(@NotNull @NotNull ExecutionContext<T> context, @NotNull @NotNull Function.Arguments arguments) Executes this function with the given arguments.- Parameters:
context- The execution contextarguments- The arguments- Returns:
- The function result
- Since:
- 3.0.0
-
evaluate
Executes this function.- Parameters:
context- The execution context- Returns:
- The function result
- Since:
- 3.0.0
-
pure
default boolean pure()Determines if this function is pure or not.A pure function is a function that has the following properties:
- The function return values are identical for identical arguments, and
- The function has no side effects
The compiler or interpreter may pre-evaluate these functions ahead of time. In case of compiling, the function may be called during compile time, to use the function's result instead.
- Returns:
- If this function is pure or not.
- Since:
- 3.0.0
-