| ▲ | Emacs internals: Deconstructing Lisp_Object in C (Part 2)(thecloudlet.github.io) | |
| 60 points by thecloudlet 3 days ago | 2 comments | ||
| ▲ | praptak an hour ago | parent | next [-] | |
SBCL uses a single zero bit to tag integers. This trick means the representation of n is just 2n, so you can add the values directly without any decoding. It obviously also means that all the other tag values have to use 1 as the last bit. | ||
| ▲ | alex_dev42 2 hours ago | parent | prev [-] | |
Excellent deep dive into the Lisp_Object implementation! The tagged pointer technique is really elegant - using the low bits for type information while keeping the actual pointer data in the upper bits. What struck me most was how this design enables the seamless transition between immediate values (like small integers) and heap-allocated objects while maintaining a uniform interface. The bit-twiddling operations to extract types and values are surprisingly clean given how much complexity they're hiding. This reminds me of how V8 handles JavaScript values with pointer tagging, though the specific bit layouts differ. It's fascinating how these foundational choices in data representation ripple up through the entire runtime performance. | ||