Recap
From the previous article, we examined how GNU Emacs represents every Lisp value — integers, symbols, cons cells, strings, buffers — inside a single 64-bit slot called Lisp_Object . Because all heap objects are 8-byte aligned and the lowest 3 bits of any valid pointer are always zero, Emacs reclaims these "free" bits and uses them as a type tag.
The more fundamental question is: when a single variable must hold values of different types at runtime, how do we preserve enough information to use that data correctly?
01. Back to the basics: how to write a polymorphic type
The static typing
Given memory and a struct type, how do we access the data?
Data in memory is represented as bits. To operate on it, we define its shape. If we modify the value of score , we load the data from base + 4 bytes , write a 32-bit value , and store it back.
#include < stdint.h > struct Person { uint8_t age ; uint32_t score ; uint64_t id ; char name [ 12 ] ; } ;
The compiler remembers the shape of the data so the runtime does not have to.
Dynamic typing
... continue reading