3 ms·
> so car and cdr are implemented with one instruction and are safe (that is, throw an exception if applied to something they don't work on) even in code compile
by hayley-patton 3y ago
> so car and cdr are implemented with one instruction and are safe (that is, throw an exception if applied to something they don't work on) even in code compiled at (safety 0).
It is? By default x86 will happily do unaligned accesses, and I'm pretty sure SBCL doesn't change that. Not sure about other instruction sets.
SBCL also uses double-word alignment and 4-bit tags, so you could CDR (expecting lowtag #b0111) a structure object (lowtag #b1111).
- pfdietz 3y agoUm, you're right. I have no idea why I thought that was the case.
- hayley-patton 3y agoIn your defense, I recall Self did use unaligned traps to deal with dispatching on heap object/immediate, when immediates didn't usually appear at a call site.