It's not a "bizarre hack", it's a very common implementation strategy known as integer tagging. You see it everywhere from OCaml to the V8 JavaScript engine.
Re:The ultimate cross platform language
by neutronicus on Wednesday August 03, 2011 @12:38PM
(#2841794)
Common Lisp also has fewer-than-32-bit integers. It uses a few bits so that the VM can tell whether something is a pointer or an unboxed integer.
No, it has fewer-than-32-bit fixnums. Integers are practically unbounded. Also, on cmucl and it's derivatives you can declare something to be (unsigned-byte 32) and when possible it will use untagged integers for performance.
This makes a difference because if you declare something "fixnum" you know you're being non-portable, but if you declare something (unsigned-byte 32) or just integer then you expect it to work across all implementations.
Re:The ultimate cross platform language
by neutronicus on Wednesday August 03, 2011 @01:09PM
(#2841944)
I didn't see a need to introduce another piece of jargon, but thanks for the clarification.
My only big problem with it was the standalone "neko" target used a bizarre hack which meant integers were limited to 31 bits. This became incredibly problematic when implementing code (e.g. drawing, file loading, interpreting bytecodes) which relied on the assumption that integers were at least 32 bits in size.
There was an official workaround which used an "Int32" class. This effectively meant if you built for "neko" you had to rewrite half your code to use Int32. Bizarrely haXe had no in-built abstraction for transparently handling 32bit integer types in this case.