3 ms·
I use FST and RST (for FIRST and REST). I like them because they are short, mnemonic, and can be composed like CAR and CDR, e.g. CADADDR = FRFRRST (though I als
by lisper 9y ago
I use FST and RST (for FIRST and REST). I like them because they are short, mnemonic, and can be composed like CAR and CDR, e.g. CADADDR = FRFRRST (though I also believe that if you find yourself doing this you're almost certainly doing something wrong).
- thatswrong0 9y agoI think I prefer this as well. I think the importance of the mnemonic aspect can’t be overstated.. even though I did get _used_ to CAR and CDR, I feel like I was never immediately able to comprehend code that used them.. I had to always perform a mental translation as if I were somewhat bad at French or something and didn’t intuitively know the words. It’s the same thing when I see test code that uses foo, bar, and baz as variables / strings instead of something more memorable like apple, banana, and cherry (or preferably something even more relevant to the code being tested). I feel like I have to work harder to understand what the tests are actually testing when I don’t have a good mental association with the variables under test. I get that it’s something programmers just do, but I’m really not a fan. Maybe I’m an odd one though.
- lisper 9y agoAnother possibility is LHS and RHS for Left Hand Side and Right Hand Side (if you want to emphasize the use of a cons cell as a pair rather than a linked list).
- kbp 9y agoDate: 5 March 1980 08:54-EST From: Mark L. Miller <MILLER at MIT-AI> To: Dave.Touretzky at CMU-10A, RWK cc: KMP, HIC, BUG-LISP Re: CAR and CDR Of course, you could rename them to, e.g., "LHS" and "RHS" for "Left Hand Side" and "Right Hand Side". This would address the composition argument in favor of CAR and CDR: CADR -> LRHS (left-hand-side of right-hand-side), CDADADR -> RLRLRHS, and so on. It's easy to provide these as macros. Later, you can explain that the original names are CAR and CDR, and isn't that silly, etc. Regards, Mark
- kazinator 9y agoShows you how resilient car and cdr have been against decades of complaining and bikeshedding. That just reaffirms them.
- lisper 9y agoI would accept that if Lisp were a runaway success, but it's not. It is very nearly a dead language [1]. It is entirely possible that the unwillingness of the Lisp community to give up in this obscure terminology in favor of something more user friendly contributed to its demise. [1] Look at e.g. https://madnight.github.io/githut/ https://madnight.github.io/githut/. The most popular Lisp is Clojure, with a whopping 0.33% market share. Scheme and Common Lisp don't even make it to the top 50.
- kazinator 9y agoCL was #45 in the car quarter of 2017; by cadr, it slipped into the long(er) tail.
- kbp 9y ago> It is entirely possible that the unwillingness of the Lisp community to give up in this obscure terminology in favor of something more user friendly contributed to its demise. What more-user-friendly terminology do you suggest?
- lisper 9y agoDid you not read the upstream comments? FST and RST, or LHS and RHS depending on whether the intent is to access the cons as a linked list or a pair.
- kazinator 9y agoThe D in CDR already corresponds to "dexter-" (right); we just need "L" for "levo-": CLR: cell levo/left reference. CDR: cell dexter reference. Organic chemistry uses these letters and prefixes. E.g. "L-glutamine", "D-glucose" (a.k.a "dextrose"). The H and S (hand side) don't really contribute anything. (Yes, left is side and a hand).
- gugagore 9y agoYou're not the first person I've heard of that doesn't like foo,bar,baz nonce variable names. But it's the first I've heard of someone preferring meaningful but irrelevant words over meaningless words. In any case, I think it makes sense, even if it's not common within programming culture.
- kazinator 9y agoYou'd have to really sneak this under the cadar if I were reviewing code.