3 ms·
Well, NaN boxing/NuN boxing would also allow you to more densely encode algebraic data type variants in statically typed languages in the case where at least on
by KMag 6y ago
Well, NaN boxing/NuN boxing would also allow you to more densely encode algebraic data type variants in statically typed languages in the case where at least one variant is a IEEE-754 double, some of the variants are references/pointers, and none of the variants take more than 8 bytes.
Granted, it's not a common use case. Neither Rust nor OCaml use this space optimization, but they could. OCaml (at least used to, back in the early 2000s) made the maximum tuple/object size smaller in other to have some bits (8 bits, IIRC) to store the variant in the object header. I'm not actually sure how Rust decides how many bits to dedicate to encoding the variant, and I have very little knowledge of GHC internals.
I'm a big fan of Rust (and to some extent, C++), but there's a ton of CPU time being spent on JavaScript execution worldwide.