partial binary_to_term?

Tony Rogvall tony@REDACTED
Sun Jan 30 11:45:13 CET 2005

On Jan 29, 2005, at 5:58 PM, Carsten Schultz wrote:

> Hi,
> I think it would be useful to have a function that interprets only the
> top level of a term in external term format.  For example with
>     T1 = {S0, S1, S2},
>     T2 = [S3, S4, S5],
>     B1 = term_to_binary(T1),
>     B2 = term_to_binary(T2)
> one head_binary_to_term(B1) would yield the same result as
> {term_to_binary(S0), term_to_binary(S1), term_to_binary(S2)}, of
> course without un- and repacking.  Similarly, head_binary_to_term(T2)
> would yield [term_to_binary(S3) | term_to_binary([S4, S5])].

If I understand you correctly this is actually possible (easy) to 
implement in erlang!
You need to find the spec's of the external format and write a library.

> For example imagine that you are receiving a list of large terms from
> an external process and want to distribute its contents to several
> other processes.  You could keep the parts packed when passing them
> on.

If you accept io-lists to be passed on. Then you can add 
"version-magic" to the parts
without constructing new binaries.

Hint: look in the erts/emulator/beam/external.[c,h]

Someone may perhaps already written this code ?

> Just a thought,
> Carsten
> -- 
> Carsten Schultz (2:38, 33:47)
> PGP/GPG key on the key servers,
> fingerprint on my home page.

More information about the erlang-questions mailing list