ChaiScript
|
Represents a function object in ChaiScript. More...
#include <chaiscript_prelude_docs.hpp>
Public Member Functions | |
string | get_annotation () const |
Returns the annotation description of the function. | |
int | get_arity () const |
Returns the arity of the function, -1 if the function takes a variable number of parameters. More... | |
Vector | get_contained_functions () const |
Returns a vector of the contained functions. More... | |
Function | get_guard () const |
Returns a function guard as function. More... | |
Vector | get_param_types () const |
Returns a vector of Type_Info objects that represent the param types for this function. More... | |
bool | has_guard () const |
Returns true if the function has a guard to it. Always returns false for a conglomerate function. | |
Object | call (Vector t_params) const |
Calls the function with the given set of parameters and returns the value;. More... | |
Represents a function object in ChaiScript.
A function object may be one function, such as:
Or it may represent multiple functions
Guarded function example
Examples in the function definitions below will reference these examples
Calls the function with the given set of parameters and returns the value;.
Example:
int ChaiScript_Language::Function::get_arity | ( | ) | const |
Returns the arity of the function, -1 if the function takes a variable number of parameters.
Example:
Vector ChaiScript_Language::Function::get_contained_functions | ( | ) | const |
Returns a vector of the contained functions.
Example:
Function ChaiScript_Language::Function::get_guard | ( | ) | const |
Returns a function guard as function.
Example:
Vector ChaiScript_Language::Function::get_param_types | ( | ) | const |
Returns a vector of Type_Info objects that represent the param types for this function.
The first value in the list is the return type.
If this function is a conglomerate of several functions (get_contained_values().size() > 0) then the function returns as many Type_Info objects as it can. If the functions contained all have the same arity, then it represents the arity. If they have different arities, it returns only one value - the return type.
For each parameter that is the same type, the type is returned. If the types are different then a Type_Info for Object is returned.
Example: