An array of
This is useful to have as its own type because we can implement faster
functions that know that they aren't dealing with float arrays and save a test for it.
We also have
set avoid the write barrier (caml_modify) in certain situations.
Just like with a regular
Array, the elements are boxed so they don't get copied by
The dynamic check this array module implements is something we hope to have implemented at a lower level (as part of the native compiler's code generation). Given that, the interface is somewhat spartan and intended for use within internal data structures.
create ~len returns an obj-array of length
len, all of whose indices have value
unsafe_set_assuming_currently_int t i obj sets index
obj, but only
works correctly if
Obj.is_int (get t i). This precondition saves a dynamic
unsafe_set_int_assuming_currently_int is similar, except the value being set is an
unsafe_clear_if_pointer t i prevents
t.(i) from pointing to anything to prevent
space leaks. It does this by setting
Obj.repr 0. As a performance hack,
it only does this when
not (Obj.is_int t.(i)).
truncate t ~len shortens
t's length to
len. It is an error if
len <= 0 or
len > length t.