News for hackers. Stuff that matters.
Re:CL21: An experimental project redesigning Common Lisp by jerf on Thursday February 19, 2015 @07:17PM (#9078126)
As a non-Lisper, I can assure you beyond a shadow of a doubt that having "car" & "cdr" show up in the first few sections of a tutorial is not something that wins people over to Lisp.

I don't mean that I don't understand it. I even know they come from assembler instruction names. And they still look weird to me and still have no meaning despite having read what the abbreviation expands to three or four times.

You'd be far better off shipping "first" & "rest" and whispering to the old hands that you're sure they know how to "fix" the problem in their code, than presenting new people with car & cdr and then try to wedge an explanation into a brain that just threw an exception and went "Wait, what?"

Re:CL21: An experimental project redesigning Common Lisp by beeworker on Thursday February 19, 2015 @08:25PM (#9078362)
Ah, but how would you easily access the number 6 out of the nested list '((((5 4 3 2 1) 6) 7) 8 9) without one of the cute compositions of "car" and "cdr"? In this case, "cadaar". (Rhetorical question. "car" and "cdr" are neat for their cute composition, but I would never inflict that on someone first learning the language.)
Re:CL21: An experimental project redesigning Common Lisp by ajuc on Friday February 20, 2015 @04:20AM (#9079650)

    (def x ((((5 4 3 2 1) 6) 7) 8 9))

    (get-in x (0 0 0 1))
Probably botched quoting, don't know common lisp, only clojure.
Re:CL21: An experimental project redesigning Common Lisp by GregBuchholz on Friday February 20, 2015 @11:34AM (#9081165)
For the heck of it, I though I'd try it in scheme with pattern matching...

  (let ((x '((((5 4 3 2 1) 6) 7) 8 9)))
    (syntax->datum
     (syntax-case x ()
       ((((_ p) _) _ ...) #'p))))
Re:CL21: An experimental project redesigning Common Lisp by chongli on Friday February 20, 2015 @04:23AM (#9079656)
One word: lenses.
Re:CL21: An experimental project redesigning Common Lisp by Flow on Friday February 20, 2015 @05:36AM (#9079854)
And how would that look for this particular example?
Re:CL21: An experimental project redesigning Common Lisp by chongli on Friday February 20, 2015 @02:53PM (#9082544)
Definitely not as terse but far more general, flexible and powerful. With car and cdr you're restricted to working on cons cells while lenses are generic.

Some examples (from Haskell):

    >>> ((((5,4,3,2,1),6),7),8,9) & view (_1 . _1 . _2)
    6
    >>> ((((5,4,3,2,1),6),7),8,9) & (_1 . _1 . _2) .~ 4
    ((((5,4,3,2,1),4),7),8,9)
    >>> let foo = ((((5,4,3,2,1),6),7),8,9)
    >>> foo & view (_1 . _1 . _2)
    6
    >>> let six = _1 . _1 . _2
    >>> foo & view six
    6
    >>> foo & six .~ 4
    ((((5,4,3,2,1),4),7),8,9)
    >>> foo & six .~ "abc"
    ((((5,4,3,2,1),"abc"),7),8,9)
Re:CL21: An experimental project redesigning Common Lisp by pnathan on Thursday February 19, 2015 @07:57PM (#9078273)
Huh.

I like the distinction of car/cdr meaning pointers vs first/rest meaning "start of list/rest of list".

It weirded me out at first, but I came to really appreciate it.

Re:CL21: An experimental project redesigning Common Lisp by jwmc on Friday February 20, 2015 @03:18PM (#9082720)
Yep. It's good to have both - the car is the first of a list, and the cdr is the rest, but a cons isn't always a list. Having first and rest exclusively would be short-changing us conceptually.
Re:CL21: An experimental project redesigning Common Lisp by TeMPOraL on Thursday February 19, 2015 @10:10PM (#9078686)
Indeed. It lets you clearly express in code that those cons cells are actually part of a different structure than a list.
Re:CL21: An experimental project redesigning Common Lisp by coliveira on Thursday February 19, 2015 @07:57PM (#9078271)
first and rest are already part of the language, no change necessary. You just need to use books that teach using first and rest instead of car and cdr.
Re:CL21: An experimental project redesigning Common Lisp by agumonkey on Thursday February 19, 2015 @10:01PM (#9078662)
I know and agree, but they have some weird syntactic/linguistic quality:

  - both 3 letters each
  - only differ by 1 letter a|d
None of the alternatives have these symmetry, and it (very subjectively) shows in the code.
Re:CL21: An experimental project redesigning Common Lisp by dragonwriter on Friday February 20, 2015 @11:19AM (#9081054)
Its not hard to think of things that meet both of those features that are still better mnemonics for things that are common-language descriptions of what the function yields (e.g., cfc/csc or c1c/c2c for "cons first cell, cons second cell")

car and cdr are mnemonics related to the particular instruction set of the first computer on which Lisp happened to be implemented, which is great for people with a background with system programming on that system, but not so good for anyone else.

They're entrenched enough in the language that they are worth changing unless you are intentionally building a new Lisp-like language from scratch with some other main motivation and the change is just a side issue -- and it is clear that having something that doesn't imply list semantics for cons cells like first/rest does is good -- but car/cdr aren't a particularly good pair.

Re:CL21: An experimental project redesigning Common Lisp by agumonkey on Friday February 20, 2015 @03:25PM (#9082766)
I know car/cdr history, and didn't like it. Only after trying clojure[1], I had a weird sensation that I was missing car/cdr and that writing in scheme felt better.

If I tried to explain deeper, Lisp focus on recursion over cons-lists was so foreign to the mainstream paradigms, that car/cdr, as most used operations, became symbolic axioms in my mind.

[1] which goes all in on the intuitive, human, pragmatic side of things, throwing away some old lisp idioms.

Re:CL21: An experimental project redesigning Common Lisp by philh on Friday February 20, 2015 @05:45AM (#9079876)
fst/rst, although having the difference in the middle also seems aesthetically appealing to me.
Re:CL21: An experimental project redesigning Common Lisp by gjm11 on Friday February 20, 2015 @10:04AM (#9080669)
Neat, but unfortunately the equivalent of CADR (second item in list: first-of-rest) is then FRST, which I think would just be too easy to misinterpret as meaning "first" when reading or writing code in a hurry.
Re:CL21: An experimental project redesigning Common Lisp by agumonkey on Friday February 20, 2015 @10:16AM (#9080722)
I don't know if cr shortcuts are still used often nowadays (SICP advocates for abstraction layers, accessor functions, CL has destruct-bind, and ml uses pattern matching to dig into data).
Re:CL21: An experimental project redesigning Common Lisp by gjm11 on Friday February 20, 2015 @11:10AM (#9080992)
Nor do I -- but I'm pretty sure that those shortcuts are pretty much the only good reason for caring much about having names that resemble CAR/CDR in the way FST/RST do. (For any other purpose, I think FIRST/REST are obviously better than FST/RST.)
Re:CL21: An experimental project redesigning Common Lisp by agumonkey on Friday February 20, 2015 @10:13AM (#9080707)
Good catch.

While writing a toy lisp I looked for other names with structural qualities, actually not names, more symbols since these weren't words.

Things like Oo/oO, xo/ox or _/__.