[racket-dev] first and rest in racket/base

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Dec 13 14:51:42 EST 2012

20 minutes ago, Carl Eastlund wrote:
> If they do the wrong thing, we should fix them, not deprecate them.

I'm not saying that they should be deprecated.

> We're not LISP, let's not promote car/cdr as the primary names for
> list operations.

And I'm not suggesting that either.  (In fact, in *C*L, `first' and
`rest' are strongly encouraged.)


A few minutes ago, Jay McCarthy wrote:
> I agree with Eli. first is not car and shouldn't be treated as it.
> 
> car : (Cons a b) -> a
> first : (List a) -> a

Right -- it's a different type, and the `list?' check adds a cost.

I don't have too much problem with how they are now -- it's just that
moving them to the base language makes it easier to think that they're
the same thing, even more in the presence of the CL thing (where they
are the same).


> I also agree with Carl that we should deprecate grandpa's names and
> give nice names. I suggest "fst" and "snd" and "pair"

Re grandpa names -- that's a kind of a discussion that happens very
frequently on practically every lisp dialect I know of.  Eventually,
there's not much to do -- and like I tell my students, I sometimes
make sure that my class notes don't have `car'/`cdr' but when I write
code in class I always get back to it.

And as for new names -- `fst' and `snd' are not good because
considering the cdr of a list as `snd' is deceptive, and because the
two names are used elsewhere as tuple accessors.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the dev mailing list.