> If I understand correctly, the problem is that using "Obj.magic 0" as
> a null causes a segfault. It is because de-reference occurs when
> inserting floats into float arrays.
The tag of the array saying it can be Double_array or 0 (normal array)
depends on the init value you create it with : if the value have the
Double_val tag then we're creating a (unboxed) float array.
In fact, you can create a boxed float array just by calling :
let fa = (Obj.magic (Array.make n 0) : float array)
that will work correctly, since insertion will test for the Double_array_tag
of the array, and not test for the inserted element tag.
But hold your breath , I'm currently working on a far better version that
doesn't need any more Obj.magic and that is working with an abstract type
which is in fact a raw ocaml block with tag 0 (exactly the same as an array,
but never makes test for Double_array_tag nor bounds checking : better since
we're already testing them in the DynArray library).