[erlang-questions] c-node and arbitrary erlang term

Roberto Ostinelli roberto@REDACTED
Wed Aug 5 14:10:12 CEST 2009


On 05/ago/09, at 01:19, Scott Lystig Fritchie wrote:

> Roberto Ostinelli <roberto@REDACTED> wrote:
>
> ro> char *e_headers = "[{one, 1}, {two, 2}]";
> ro> erlterm = erl_format("~w", e_headers);
>
> I agree with Per, that won't work.  However, this should, if memory
> serves correctly.
>
>    ETERM *erlterm = erl_format("[{one, 1}, {two, 2}]");
>
> erl_format() won't  work well with  C programs with limited  stack  
> sizes
> (e.g. when using Pthreads).  It uses naive recursion for formatting
> nested terms, which can cause problems for deeply-nested and/or
> extremely long lists.  In those cases, you can usually get by with a
> small number of intermediate steps.
>
>    ETERM *very_long_list = format_myself_by_hand(a_long_linked_list);
>    ETERM *my_tuple = erl_format("{ok, ~w}", very_long_list);
>
> IIRC, erl_format() doesn't have a format command for dealing with
> binaries.  But the ~w format command will work on a previously-created
> binary, e.g. ETERM *my_bin = erl_mk_binary("Hello!", 6).
>
> -Scott

thank you scott,

yes my point was i hoped i could get an erlang term already parsed at  
c level, instead of transmitting strings over. however i'm not even  
actually sure this would change anything in performance, so that will  
do.

cheers,

r.



More information about the erlang-questions mailing list