2 points by Pauan 2684 days ago | link | parent My interpreter treats 'nil and nil as separate. Not sure if that's a good idea, but I'd rather wait and see if it causes problems before changing it:`````` (is 'nil nil) -> nil `````` This does raise one interesting question, though... obviously 'nil is a sym, but if (is nil ()) is t, then shouldn't (type nil) return 'cons?
 2 points by waterhouse 2682 days ago | link () is not a cons cell, and while (car ()) is well-defined (to be nil), you can't set the car or cdr of (). It is definitely not a cons.On the other hand, (listp nil) should be true. In fact, its precise definition should probably be (and is, or is equivalent to) this:`````` (def listp (x) (or (is x nil) (and (acons x) (listp (cdr x)))))``````-----
 2 points by evanrmurphy 2682 days ago | link "Actually, I could represent nil as an actual 'cons cell, so that assigning to the car or cdr would work. Crazy?"That's a bit crazy. :)PicoLisp does something reminiscent. Every one of its data structures (numbers, symbols, nil and conses) is implemented using the low-level cons cell structure (i.e. a pair of machine words). [1] They talk about nil's representation fulfilling its dual nature as both a symbol whose value is nil and a list whose car and cdr are nil; both the symbol predicate and the list predicate return true when applied to nil:`````` : (sym? NIL) -> T : (lst? NIL) -> T `````` I'm not sure that they let nil's car and cdr be assignable though, because "NIL is a special symbol which exists exactly once in the whole system." [2]----Update: Oops, I just noticed a lot of this comment could be considered redundant with the grandparent comment by waterhouse. Sorry for that.-----