[erlang-questions] unexpected result of term_to_binary

Robert Virding <>
Tue Jan 22 18:35:48 CET 2013

I don't see the problem. Erlang doesn't have strings, it only has lists of integers so unless you start tagging things there is no safe way to differentiate between them. As a general list can be a list of anything so the encoding must be able to handle this. However, the encoding special cases a list of small (<256) integers and uses a more compact representation. That it calls it a STRING_EXT doesn't really mean anything, they could just as well have called it LIST_OF_SMALL_INTEGER_EXT instead. The description of STRING_EXT actually says this:

"String does NOT have a corresponding Erlang representation, but is an optimization for sending lists of bytes (integer in the range 0-255) more efficiently over the distribution."

So why not just treat it as such?


----- Original Message -----
> From: "Steve Davis" <>
> To: "Richard O'Keefe" <>
> Cc: "Erlang Questions" <>
> Sent: Tuesday, 22 January, 2013 2:29:54 PM
> Subject: Re: [erlang-questions] unexpected result of term_to_binary
> Because I was writing an ETF decoder for a language that does make a
> distinction between strings and arrays of integers, and wanted to
> avoid constraints on the kinds of terms that could be sent from the
> erlang side of things.
> On Jan 21, 2013, at 11:23 PM, "Richard O'Keefe" <>
> wrote:
> > 
> > On 22/01/2013, at 8:38 AM, Steve Davis wrote:
> > 
> >> The following appears to encode lists of integers as strings
> >> (?!?):
> >> 
> >> Is there a reason for this that I'm missing?
> > 
> > Why do you _care_ what the encoding is as long as it decodes
> > correctly?
> _______________________________________________
> erlang-questions mailing list
> http://erlang.org/mailman/listinfo/erlang-questions

More information about the erlang-questions mailing list