3 ms·
A long time ago I settled on FST and RST as the Right Names for the two halves of a cons cell. The argument is: 1. It's vaguely mnemonic of FirST and ReST, b
by lisper 6y ago
A long time ago I settled on FST and RST as the Right Names for the two halves of a cons cell. The argument is:
1. It's vaguely mnemonic of FirST and ReST, but compactified enough that it's still parseable as abstract names with no particular semantics
2. It's composable the same way that CAR and CDR are, e.g. FFRST == CAADR.
Another good pair of names is LHS and RHS for Left Hand Side and Right Hand Side. Same argument applies.
- Riverheart 6y agoHow do you define these so you can use them like CAADR?
- lisper 6y ago(defun ffrst (l) (caadr l)) Lather, rinse, repeat. For extra credit, write a macro that will save you having to type every possible combination out manually.
- emidln 6y agoI did this once for Clojure and named it car-cdr-construction-set! with an argument for how many levels deep to define in the current namespace.
- agumonkey 6y agoSome people in university hinted that some lisps had special parsing stages for car/cdr based functionals. They may turn c(.)*r into nested (car (cdr ( ... ) ) ) calls.