5 ms·
If they have the same semantics why doesn't the library do an unboxing implementation for types that support it and not for the rest?
by bcoates 14y ago
If they have the same semantics why doesn't the library do an unboxing implementation for types that support it and not for the rest?
- tedunangst 14y agoThis sounds like exactly the sort of optimization that I'm always hearing a sufficiently smart compiler will make for me.
- PaulAJ 14y agoNo, because compilers are prohibited from changing the meaning of the program. Changing a lazy value to a strict value is only permitted when the compiler can prove that the value will always be evaluated. It can't do that for unboxed arrays because that is a global change, so it has to leave it to the programmer.
- ramchip 14y agoThe semantics are different with regard to lazyness: a boxed vector can contain thunks (unevaluated values), so individual elements can be evaluated on demand, while an unboxed vector must be evaluated all at the same time (making it difficult to run a transformation in parallel with multiple threads, for example).