[erlang-questions] Announcing eipp: erlang bindings for c++
Fri May 18 04:25:44 CEST 2007
I'm not especially familiar with erl_interface, so I'll just talk a bit
about eipp so you get a feel for it.
The main class in eipp is "et" (erlang term). It is essentially a
variant type inspired by the "any" class from the boost library (earlier
revs were actually directly derived from boost::any). Any type that can
be transported by erlang etf can be represented by an et. Example:
eipp also provides runtime automatic casts for getting things out of et:
int x; double y; int z;
z=c; // throws bad_match exception, can't convert atom_t to int
eipp also has named constructors and destructurers for lists and tuples
(inspired by boost::tuple).
et supports the insert operator:
cout << a << endl;
eipp has a binary type, the primary use of which is for storing
serialized et instances. The binary type is really a pointer to
std::vector<char>, so you would need to drill into that type to get at
the raw data (ie, for transmitting through a socket for example).
sendN() functions are provided to send binaries to an iostream in a
format compatible with erlang port packet format.
Similarly, receiveN() functions are provided for receiving terms.
Internally, et instances decoded from a binary are different from
natively constructed et instances. Decoding is done "lazily", meaning
that the binary is kept around and the term is decoded just-in-time
(tuples and lists must be eagerly converted however, but not their
contents). The advantage to this is that unneeded terms don't have to
be decoded, and terms that are often not needed by a c++ program (funs,
pids) can be sent back to a real erlang node without ever being decoded.
All memory is automatically cleaned up (hooray for boost::shared_ptr !),
even for a bunch of decoded terms that may refer to the same binary.
eipp uses the encode & decode functions from ei, although I'd like to
work on producing native c++ transcoders. eipp does not do the erlang
distribution protocol, although that's something I'd like to add eventually.
Dmitrii 'Mamut' Dimandt wrote:
> Daniel Goertzen wrote:
>> I'm please to announce "eipp": erlang bindings for c++. My employer
>> allowed me to open source this library, so many thanks to
>> http://www.norscan.com .
> I've reposted your announcement to a russian site, http://rsdn.com
> I've been immediately asked the following:
> - How is it better than erl_interface?
> - There is no C++ in the example
> - Does cleans up terms automatically on free_term()?
> All this I resend to you as I've had just a tiny peek at the code and
> can't answer those questions for sure.
> Though my guess for eipp vs. erl_interface is that eipp is, at the very
> least, much less verbose.
> Go eipp :)
> erlang-questions mailing list
More information about the erlang-questions