cdaddr is very rarely used, because the ANSI CL versions of these functions only go four "letters" deep: car, cdr, caar, ..., cddddr.
For understandability, what you might want to reach for is:
;; d <- (cdaddr obj)
(destructuring-bind (a b (c . d) . rest) obj
d)
or else some pattern matching macro that doesn't require dummy variables up to d. For a single, one-off retrieval of a buried value, it doesn't compete with cdaddr.
But that particular ANSI CL construct isn't as forgiving; if the list doesn't have that (c . d) node, you get a destructuring error. Whereas cdaddr will only give you grief if any car or cdr step encounters a non-nil atom. You can't blindly substitute one for the other.
If you have to get several neighboring objects from the tree at that depth, using the cdaddr type function would be inefficient, because you're traversing the full path from the root multiple times. For that reason, efficient destructuring and pattern matching won't use them.
Still, in TXR Lisp, I provide these things to five levels deep.
Not only that, but I have provided numeric access to Lisp structure, which I borrowed from none other than ... Urbit!
Unlike Urbit, I have both big-bit-endian and little-bit-endian access; I call the functions cxr and cyr.
For understandability, what you might want to reach for is:
or else some pattern matching macro that doesn't require dummy variables up to d. For a single, one-off retrieval of a buried value, it doesn't compete with cdaddr.But that particular ANSI CL construct isn't as forgiving; if the list doesn't have that (c . d) node, you get a destructuring error. Whereas cdaddr will only give you grief if any car or cdr step encounters a non-nil atom. You can't blindly substitute one for the other.
If you have to get several neighboring objects from the tree at that depth, using the cdaddr type function would be inefficient, because you're traversing the full path from the root multiple times. For that reason, efficient destructuring and pattern matching won't use them.
Still, in TXR Lisp, I provide these things to five levels deep.
Not only that, but I have provided numeric access to Lisp structure, which I borrowed from none other than ... Urbit!
Unlike Urbit, I have both big-bit-endian and little-bit-endian access; I call the functions cxr and cyr.
https://www.nongnu.org/txr/txr-manpage.html#N-01DA4F04
I seem to have under-documented this (probably also inspired by Urbit), but the test suite has a bit of coverage: