Erlang interfacing
From Reia
As Reia is built on top of Erlang, it can borrow heavily from Erlang's standard library. Most of Reia's standard library will initially consist of wrappers around the Erlang standard library which will add a more Reia-esque feel to them.
But more than that, Reia is intended to exist with existing Erlang projects. Reia can be used for testing or building functionality on top of existing Erlang applications. One of the anticipated uses is adding web interfaces to Erlang applications.
Contents |
Calling out to Erlang from Reia
The current Erlang interfacing syntax is not finalized and may be subject to change.
Erlang functions can be presently called using the module::function(arg1, arg2, ..., argN) syntax. Future versions of Reia will use the :: operator as the namespace resolution operator, however unlike some silly languages Reia should be able to use the '::' operator for both purposes.
Example:
>> io::format("Hello, world!~n".to_list())
Hello, world!
Calling out to Reia from Erlang
The 'reia' module in Erlang provides a set of functions for interfacing with the Reia environment.
Parsing Reia
The reia:parse function returns the parse tree of a Reia expression:
> reia:parse("2+2").
{ok,[{op,1,'+',{integer,1,2},{integer,1,2}}]}
Calling Reia modules
Reia modules can be invoked with the reia:apply function:
> reia:apply('Foo', 'bar', [1,2,3]).
{ok, 6}
Creating Reia objects
reia:spawn and reia:spawn_link allow you to create new object instances:
> Object = reia:spawn('Object', []).
{object,{<0.39.0>,'Object'}}
Invoking methods on objects
reia:invoke allows you to call methods on objects:
> reia:invoke(Object, class, []).
{constant,'Object'}

