4 ms·
I dunno, as a latecomer lisp-enthusiast, that cadaddaaadr stuff seems heinous to me.
by s_kilk 10y ago
I dunno, as a latecomer lisp-enthusiast, that cadaddaaadr stuff seems heinous to me.
- kazinator 10y agoI've grown to like it, and implemented it in TXR Lisp one level deeper than CL, all the way to cddddr. http://www.nongnu.org/txr/txr-manpage.html#N-03E5CED9 http://www.nongnu.org/txr/txr-manpage.html#N-03E5CED9 The code for them is generated textually: http://www.kylheku.com/cgit/txr/tree/gencadr.txr http://www.kylheku.com/cgit/txr/tree/gencadr.txr
- kruhft 10y agoIt's not pretty, but it has a consistency to it that includes a lot of compact information in a digestable manner. It takes no longer to decode what the instructions say, but it saves a lot of time parsing, for the human reader of the program. Compare: (caadar x) => (car (car (car (cdr (car x))))) Saves parens too.
- kbp 10y agoYou can make it even easier on human readers by defining accessors (even if they're just wrappers over car/cdr) and giving them meaningful names. Asking for the car of the car of the cdr of the car of an ad-hoc data structure is pretty hostile toward human readers regardless of whether or not you use caadar.
- junke 10y agoThat's why you actually won't find many instances of such patterns in practice. Either you refactor to have structures/classes, or you define your own accessors. Besides, if you are using CL, FIRST, SECOND, THIRD, ... , TENTH, NTH and REST are defined by the spec (http://clhs.lisp.se/Body/f_firstc.htm http://clhs.lisp.se/Body/f_firstc.htm).