3 ms·
I'm not really qualified to explain why such a layout was chosen, my understanding of ocaml internal is limited. The header layout is described here : https://
by jorisgio 9y ago
I'm not really qualified to explain why such a layout was chosen, my understanding of ocaml internal is limited. The header layout is described here :
https://github.com/ocaml/ocaml/blob/4.04.2/byterun/caml/mlvalues.h#L82 https://github.com/ocaml/ocaml/blob/4.04.2/byterun/caml/mlva...
I believe it's internal to the compiler/runtime/C interface (but hidden under abstraction), unless Marshal (an unsafe low level binary serialization format for ocaml values depends on it)
The lowest byte is filled with the tag. I guess it should be possible to swap the color and the tag, or put the color at the beginning before the size, but that probably would have a different tradeoff.
The tag is used for instance in pattern matching and in a lot of code. With this layout it can be accessed easily, which might be the reason the color is put in the second byte