[erlang-questions] Spurious '100' in array:new

Luke Bakken <>
Mon Jan 28 16:36:51 CET 2019


Hi Donald -

I have never used the array data type, but I assume that the 100 is an
internal implementation detail.

https://github.com/erlang/otp/blob/OTP-21.2.4/lib/stdlib/src/array.erl#L151-L160

Notice that the last element in the array record is for "elements",
which are defined immediately above the record in the source code.
non_neg_integer() can be the sole element in your array, and is
determined by this code:

https://github.com/erlang/otp/blob/OTP-21.2.4/lib/stdlib/src/array.erl#L286-L298

In your case, the ?extend macro is evaluated and the result of 10 *
(NODESIZE * LEAFSIZE) is stored in the elements field of the record.

At least, I think this is the correct reading of this code :-)
Thanks,
Luke

On Sat, Jan 26, 2019 at 8:11 AM Donald Steven <> wrote:
>
> When I declare a new fixed-size array (of 19 values) within a map, with the statement:
>
> Sound = #{
>
>     contourTag =>  SndContour   = array:new(19, {default,{0, unspecified, 0}}),
>     ...
>
> },
>
> and print it out using io:format and ~p, I get:
>
> Sound: #{contourTag => {array,19,0,{0,unspecified,0},100},
>
> ---
>
> Where is the '100' coming from?
>
> Thanks.
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions


More information about the erlang-questions mailing list