[erlang-questions] Re: Some ei questions

Alexey Romanov <>
Fri Nov 19 17:06:47 CET 2010

Thank you for http://www.trapexit.org/How_to_use_ei_to_marshal_binary_terms_in_port_programs
which is what got me started with ei.

On Fri, Nov 19, 2010 at 6:44 PM, Serge Aleynikov <> wrote:
> 1. External term encoding format treats small integers fitting in one byte
> differently from larger ones, and therefore has a special encoding type for
> them.  From the definition of this encoding it's highly unlikely that that
> would change as such a change would not be backward compatible.
> 2. You can decode it with either one of the two functions.  The difference
> between these functions is in the amount of space you give them to store the
> decoded result, but they are smart enough to handle different types of
> integers.

Got it.

> 3. Even though ei_get_type() and ei_decode_binary() specify different types
> of length (on 64-bit platforms), a binary value is limited to 4G, and
> therefore in practice this discrepancy is irrelevant (though not very
> elegant).

This still leaves us with binaries over 2G. I believe the overflow
works out correctly anyway.

> Serge
> On 11/19/2010 6:26 AM, Alexey Romanov wrote:
>> And also, while I am at it: why is there mismatch between arguments of
>> ei_get_type (int *size) and ei_decode_binary (long *len), given that
>> documentation states "The size required can be fetched by
>> ei_get_type()"? How can the size of a binary be obtained in case it
>> doesn't fit into int?
>> Yours, Alexey Romanov
>> On Fri, Nov 19, 2010 at 12:25 PM, Alexey Romanov
>> <>  wrote:
>>> 1. ei.h says about ERL_SMALL_INTEGER_EXT etc. "Defines used for
>>> ei_get_type_internal() output; we don't want to export these". Are
>>> they likely to go away in next release or two? Should some other
>>> #defines be used for output of `ei_get_type()` (not
>>> `ei_get_type_internal()`)?
>>> 2. ERL_SMALL_INTEGER_EXT should be decoded with ei_decode_long() and
>>> ERL_INTEGER_EXT with ei_decode_longlong()? Or something different?
>>> Yours, Alexey Romanov
>> ________________________________________________________________
>> erlang-questions (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:

More information about the erlang-questions mailing list