News for hackers. Stuff that matters.
Re:The Empty List by Chinjut on Saturday December 17, 2022 @12:53PM (#34030251)
If NIL were a CONS, how would you distinguish between an empty list and a list of length one containing NIL?
Re:The Empty List by lisper on Saturday December 17, 2022 @01:18PM (#34030538)
The same way you do now: (NIL) would not answer true to NULL. And it would not be EQ to NIL.
Re:The Empty List by Chinjut on Saturday December 17, 2022 @05:07PM (#34032765)
If NIL were a CONS whose CAR is NIL and whose CDR is NIL, wouldn't NIL be the same as (CONS NIL NIL) = (NIL . NIL) = '(NIL)?
Re:The Empty List by tmtvl on Saturday December 17, 2022 @05:26PM (#34032932)
Technically not, because a cons of two objects is not eq to another cons of the same two objects.

  (eq (cons 1 2)
      (cons 1 2))
  ;; => nil
It's memory locations, after all.
Re:The Empty List by Chinjut on Saturday December 17, 2022 @05:32PM (#34032970)
I see, fair enough. I forgot to switch out of pure functional programming/referential transparency mode for this discussion. Fine, you can take NIL to be one particular (NIL . NIL) that's different from all other (NIL . NIL)s, the only particular (NIL . NIL) that is considered a list of length 0 while all other (NIL . NIL)s are lists of length 1.
Re:The Empty List by lisper on Saturday December 17, 2022 @05:20PM (#34032893)
It depends on what you mean by "the same". It is already "the same" in the sense that the CAR and CDR of both NIL and (NIL) are all NIL. They just aren't EQUAL, despite the fact that their CARs and CDRs are EQUAL (in fact, they are all EQ).