News for hackers. Stuff that matters.
Re:The Origin of CAR and CDR in Lisp (2005) by kazinator on Tuesday December 26, 2017 @07:38PM (#16011996)
> The 90% case here is "second", "third", etc.

Unfortunately, those cases exhibit poor style if they are mixed with cddr. For instance, I would never write this:

  (when (and (consp (cdr x)) (consp (cddr x)))
    (do-something (third x)) ;; ouch!
    )
If we checked that cddr is a cons, we then want to access caddr (its car) or cdddr (its cdr).

Those first, second, rest and whatnot are really geared toward when the structure is a (proper!) list. If it really is just a proper list and we just want to be sure it has a third element, it would be more consistent to just do

   (when (>= (length x) 3)
     (do-something (third x))
Basically stick to one way or the other.

There are no comments on this comment yet.