News for hackers. Stuff that matters.
Re:The Origin of CAR and CDR in Lisp (2005) by dang on Monday December 26, 2016 @01:11PM (#13259129)
One interesting thing here is that the attempt to get people to stop using the 'bad' names car and cdr is only a few months younger than car and cdr themselves. This is analogous to the plan (which lasted a few years) to replace s-expressions with m-expressions. In both cases the 'bad' construct stuck around because it's easier to program with.
Re:The Origin of CAR and CDR in Lisp (2005) by abecedarius on Monday December 26, 2016 @06:34PM (#13260342)
When I made my own Schemes back in the 90s, I included the ca/dr primitives, because yes, they were handy -- but coming back to this recently I didn't bother, because I built in pattern matching instead. I imagine that'll finally kill off the caaddars in most new Lisps.
Re:The Origin of CAR and CDR in Lisp (2005) by dang on Monday December 26, 2016 @06:43PM (#13260374)
What did you do recently?
Re:The Origin of CAR and CDR in Lisp (2005) by metaobject on Monday December 26, 2016 @06:53PM (#13260407)
To add to that question ... how did you use pattern matching to replace the composability of car/cdr?
Re:The Origin of CAR and CDR in Lisp (2005) by abecedarius on Monday December 26, 2016 @07:53PM (#13260609)
My new Lisp dialect is https://github.com/darius/squeam (and as it says, I'm not wishing it on anyone else).

Pattern matching would replace a call like cadar with a pattern like ((_ x @_) @_). Using cadar is sort of like point-free style in Haskell: they both invite you to mentally run a chain of operations to understand the meaning, in contrast to patterns and expressions with named variables, which are more like a picture of the input and output.

Of course pattern matching goes way back, but I used to think of it as less settled -- people might want to extend the kernel language with pattern matching in many different ways. Now I'd be more surprised by a new Lisp without some sensible default; plus if it is absent, you can add it in under a page of code, like http://okmij.org/ftp/Scheme/macros.html#match-case-simple

Re:The Origin of CAR and CDR in Lisp (2005) by kruhft on Monday December 26, 2016 @10:03PM (#13261022)
Thank you for sharing your work. I could see some good use out of it.
Re:The Origin of CAR and CDR in Lisp (2005) by abecedarius on Tuesday December 27, 2016 @05:51PM (#13266937)
I hope it does become useful, thanks! So far it's more of a hobby.
Re:The Origin of CAR and CDR in Lisp (2005) by lmm on Monday December 26, 2016 @05:29PM (#13260118)
I think people might still start new s-expression based languages, whereas any respectable new language will use head/tail rather than car/cdr.
Re:The Origin of CAR and CDR in Lisp (2005) by dang on Monday December 26, 2016 @06:39PM (#13260355)
I don't know about respectable, but I prefer car/cdr even in a new Lisp. In addition to the composability of the notation, which others have cited, there's the clear lexical symmetry between the two; their compactness, which adds value when writing and reading concise programs; and how easy they are to say out loud. There's something also about their precision: when you say 'car' or 'cdr' in a Lisp context it's immediately clear that there's a linked list at hand and you're talking about it.

The main disadvantage is that they're words with no immediate connection to their meaning, but that's true of many words we're all familiar with. It really only costs anything in the learning stage—which admittedly is a critically important stage. But I think it's fair for a programming language to use specialized idioms for a small number of their most fundamental constructs.

Re:The Origin of CAR and CDR in Lisp (2005) by bluefox on Monday December 26, 2016 @07:34PM (#13260549)
CAR and CDR are also good names because they are part of the Lisp tradition. Also due to this tradition, they have a clear meaning in the context of Lisp. If the "new Lisp" keeps conses (and some may argue that if it doesn't, it shouldn't really fall under "a Lisp"...), perhaps it should also keep these names.
Re:The Origin of CAR and CDR in Lisp (2005) by Turing_Machine on Monday December 26, 2016 @06:03PM (#13260241)
First and rest make more sense if you're only going one level down, true. Long-term Lisp fans will argue that the composability shorthand of caddar, cddddr, cadadar, etc. is just too useful to give up.
Re:The Origin of CAR and CDR in Lisp (2005) by aninhumer on Tuesday December 27, 2016 @09:21AM (#13263241)
I think needing to use such operators is already indicative of inadequate tools to express structure.

And if I did need to use something as complex as `cadadar` frequently for some reason, I'd much rather give it a name (and a type) that expresses what I'm actually doing with it.

Re:The Origin of CAR and CDR in Lisp (2005) by Turing_Machine on Wednesday December 28, 2016 @03:03AM (#13269138)
Well, the point is not that you use cadadar all the time as such, but that you also use cdddar, caadr, and so on, and that having these shorthand forms available means that you don't have to define a whole bunch of one-off functions.
Re:The Origin of CAR and CDR in Lisp (2005) by aninhumer on Wednesday December 28, 2016 @05:28AM (#13269670)
I think saying you can use `cadadar` to operate on a data structure instead of defining an accessor is like saying you can use pointer arithmetic to work with data structures in C instead of using structs.

EDIT: And as other people have mentioned, most serious lisps already have proper tools for building data-structures, so I'm inclined to think that if you're using `cadadar` you're probably doing something wrong.

Re:The Origin of CAR and CDR in Lisp (2005) by Turing_Machine on Thursday December 29, 2016 @01:17AM (#13275950)
"I'm inclined to think that if you're using `cadadar` you're probably doing something wrong."

That's nice. I'm inclined to think that you haven't written very much Lisp code.

Re:The Origin of CAR and CDR in Lisp (2005) by kbp on Monday December 26, 2016 @07:05PM (#13260444)
Conses are arbitrary pairs, not necessarily lists. car and cdr are what eg OCaml and Haskell call fst and snd.
Re:The Origin of CAR and CDR in Lisp (2005) by chj on Monday December 26, 2016 @11:01PM (#13261202)
Think of them as tools or symbols, like Sigma or Pi. Make peace and move on.