5 ms·
The comment was about adding an extra bit for color in the pointer itself—not in the object. It's not a question about type safety, Java simply has no mechanis
by dietrichepp 12y ago
The comment was about adding an extra bit for color in the pointer itself—not in the object.
It's not a question about type safety, Java simply has no mechanism to make this possible (a decision which was influenced by type safety concerns).
- ProbonoBonobo 12y agoThat's interesting, I hadn't considered the possibility of attaching bytes to pointers before (although the flavor of the idea reminds me a little bit of certain SICP exercises I struggled with, but in a slightly different terminology). It sounds like a powerful idea. For one, it sounds like weighted graphs would lie in your hand, so to speak: you could traverse and compose them (anonymously, if you like) without necessarily creating any new objects. Is this right, or am I just daydreaming?
- joelwilliamson 12y agoI think you're reading too much into the idea. If all memory is word-aligned, you only get 2 bits on a 32-bit machine and 3 bits on a 64-bit machine. If your property can't be encoded in 2 bits, it's probably not worth the trouble. OCaml uses the low bits to encode some basic type information for the GC. Pointers have both low bits 0, integers have the lowest bit set, and sum types have the lowest bit unset and the second bit set. This means integers are 31/63 bits long and using native-sized integers carries a significant performance penalty.