[erlang-questions] Re: Some ei questions

Serge Aleynikov serge@REDACTED
Fri Nov 19 16:44:45 CET 2010


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.

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).

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
> <alexey.v.romanov@REDACTED>  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-unsubscribe@REDACTED
>


More information about the erlang-questions mailing list