[erlang-questions] More elegant way to

Damien Towning connolly.damien@REDACTED
Sun Jun 24 12:36:40 CEST 2018


Hi everyone,

I have some c code using c_node that I have successfully got working with
Erlang ( through Elixir ) and I am wondering if on the C side a more
elegant way exists to pass data back to the Erlang/Elixir than what I am
currently doing.  My C code looks a bit like this.

 else if (erl_match(msg_pattern_b, emsg->msg)) {
    ETERM *term = erl_var_content(msg_pattern_b, "Term");
    response = erl_format("{ok, ~w}",erl_mk_string(floats_as_string()));
    erl_free_term(term);
  }

 I've parsed a series of floats in to a char * and then passed that back to
erl_mk_string().

I hope I have framed this question in a way that makes sense. I'd like to
take a list of floating point values directly and pass it directly back to
my calling Elixir code as a list without having to parse it in and out of a
string.

Is this possible. I have spent quite a bit of time now digging through the
erl_ documentation and trying to find an example but I just can't quite see
it.

Thanks !
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180624/6c4f18eb/attachment.htm>


More information about the erlang-questions mailing list