2 ms·
The bit twidling means that you can store any kind of Ocaml value in a single machine word. https://realworldocaml.org/v1/en/html/memory-representation-of-valu
by ufo 12y ago
The bit twidling means that you can store any kind of Ocaml value in a single machine word.
https://realworldocaml.org/v1/en/html/memory-representation-of-values.html https://realworldocaml.org/v1/en/html/memory-representation-...
This makes the generated executables less efficient but it makes the lives of the compiler and garbage collector easier: Every single variable or function parameter has the same size and you can easily tell if a value is a pointer or not just by looking at it.
In a way, its a little bit like executing bytecode in a virtual machine. The executable does some extra bit twiddling, boking and tagging but lots of things get simpler because of the uniform value representation.
> But seriously, is there code that isn't heavy on integer arithmetic or floating point operations? Do computers do anything else?
Lots of software nowadays is bottlenecked by the speed of network interfaces or RAM, meaning that the arithmetic speed isn't a big factor.
- StefanKarpinski 12y agoThanks, that's a reasonable explanation. I can see how storing every value in exactly one machine word and having the low bit always indicate whether a value is immediate or a pointer is a nice simple design.