3 ms·
I'm confused. In OCaml, the type system is strong and statically typed, ergo the type of a value is known at compile-time. So...why would it need to do this t
by Solvency 3y ago
I'm confused.
In OCaml, the type system is strong and statically typed, ergo the type of a value is known at compile-time.
So...why would it need to do this to check if the type is an integer?
- dpwm 3y agoFor garbage collection, which operates at runtime. Integers are unboxed; every other type requires additional data.
- kaba0 3y agoOCaml uses a very very naive runtime representation for heap-allocated objects, so I guess that’s the reason.
- WastingMyTime89 3y agoPolymorphism. This trick allows Ocaml to pass unboxed integer to polymorphic functions. It’s about compiled code by the way, a lot lower down the stack. That’s the joy of working on a compiler. You deal with both very high level concepts and very low level issues.
- rickstanley 3y agoAlso, just out of curiosity, how would one go about removing out these extra steps? I don't program in OCaml, but I'm fascinated by it.