It's usual programming style to use CAR/CDR when working with CONS trees/graphs and FIRST/REST when working with lists.
It's usual programming style to use CAR/CDR when working with CONS trees/graphs and FIRST/REST when working with lists.
Do I think it's a big problem? Not really. Are the names less than optimal? Yes.
> Are the names less than optimal? Yes.
I don't think that's self-evident. The only better alternatives I've ever heard suggested are something like left and right, which I think are probably slightly clearer names for what the functions do, but not significantly so (I don't think "a cons is a thing with a left and right side" is that much more intuitive than "a cons is a thing with two parts called a car and a cdr").
Further, I think in 1959 when most everyone using Lisp was hacking on the implementation itself, names that are mnemonic for what the machine they were actually using is actually doing make sense; I don't think they're clearly sub-optimal now, but I think they were even less so in 1959.
(And then you ask me what would be a better name, and I don't have a perfect answer. "left" and "right" are the best I know of...)
I think it's perfectly acceptable if there aren't really any better names for the abstraction you're creating. car and cdr work just fine as made-up arbitrary names for an abstraction that doesn't really have any more natural names for them; the fact that 60 years ago they weren't actually entirely arbitrary doesn't really change that.
By the way, the C and R are not machine specific; any machine can have a "register" and any register can have "contents". On any machine where we implement cons cells, we can just call the two fields registers, understood as being A and D.
These, in turn, can be "ante" and "de", if someone desperately needs mnemonics:
https://en.wiktionary.org/wiki/ante
https://www.etymonline.com/word/de-
"active word-forming element in English and in many words inherited from French and Latin, from Latin de "down, down from, from, off; concerning."
> By the way, the C and R are not machine specific; any machine can have a "register"
Slight nitpick: the first machine on which I had a decent Lisp to use (Portable Standard Lisp) was a Burroughs 6800, a stack machine with no general purpose registers, or indeed any registers directly accessible by the programmer.
If a cons cell is a context with two registers (R) whose contents we can access (C), the only vestiges of that IBM machine are the A and D letters sandwiched in between to distinguish them.
Compared to how option letters change meaning between Unix commands, it's nothing. -h help? Nope, h)uman readable sizes.
^ to anchor regex at beginning; $ for end. Because on common keyboards, ^ is on the right, and $ on the left!