-
Notifications
You must be signed in to change notification settings - Fork 37
Erlang Interfacing
Reia provides support for embedding within an existing Erlang application and calling Erlang functions directly from Reia code.
Reia provides special syntax for calling Erlang functions:
erl.module.function(arg1, arg2, arg3)
The special keyword "erl" is used to signify you want to make a call to native Erlang code. The above code snippet is equivalent to the following Erlang code:
module:function(Arg1, Arg2, Arg3)
A special syntax is available in Reia for calling functions from the "erlang" module:
erl.length([1,2,3]) # returns 3
The reia module defines a set of functions for embedding Reia within your existing Erlang application. The following functions in the reia module can be used for loading and invoking Reia code from within an existing Erlang application:
Initializes the Reia environment within the Erlang VM. Returns an ok atom, or raises an exception if there was a problem locating the Reia distribution. You will need to call this function before invoking any other Reia interfacing functions.
Load the given Reia source code file. If successful, returns an ok tuple with the given Erlang and Reia module identifiers. Otherwise, returns an error tuple with the given error identifier.
Evalutes the given Reia code, specified as a string. Optionally accepts an input binding (given in the form of a list of key/value tuples, e.g. [{a,1},{b,2},{c,3}], which represents variable "a" being bound to 1, "b", being bound to 2, etc.)
A value tuple is returned upon success. Otherwise, an exception is thrown.
Call the given function of a Reia module, returning the result.
Create a new instance of the given Reia class, passing the given arguments and/or block to the class's initialize method.
Invoke the given method on a Reia object (as returned from reia:inst), returning the value from the method when called with the given arguments and/or block.
Generates a native Reia exception of the given class and throws it
Create a Reia string from a native Erlang list of characters
Create a Reia string from a native Erlang binary