Wren::VM
High level interface to Wren
Constructors
Class methods
Instance methods
Call a method in a Wren object, passing values as needed
Runs source, a string of Wren source code in a new fiber in the vm, in the context of resolved module mod. Raises exceptions in case of compile or runtime errors
Macros
Wraps any proc with any number of arguments into a CallbackFunction
so it can be registered with the Wren interpreter using
#register_function()
The first argument is the Wren::VM.@id for the VM where this function
will be used. This is sort of ugly but I have found no workaround.
Arguments should have simple types like Float64 or String and
they are casted using as() so if the actual argument passed from
Wren is the wrong type it will raise an exception.
You can register multiple functions for the same name if their arity is different.
FIXME: since Crystal is polymorphic by type+arity and Wren is only polymorphic by arity, so maybe support multiple functions of the same arity wrapped together and dispatch to the one that matches signature of the received arguments?