Page 1 of 1

Why () not evaluate to nil?

Posted: Sun Feb 27, 2011 8:45 pm
by anemo
Why doesn't () evaluate to nil?

it seems weird to be a lisp language and have that not be true. Just a strange philosophical question I had when I hit something unexpected.

Just a random philosophical question I had. To be honest it doesn't change much for me, but got curious since some "super serious 'other' lisp dude" would think that it's a big deal.

Re: Why () not evaluate to nil?

Posted: Sun Feb 27, 2011 10:40 pm
by Lutz
There is a chapter about this in the newLISP Users Manual Chapter "10. nil, true, cons, and ()"

http://www.newlisp.org/downloads/newlis ... l_and_true

This and related matters are also discussed in The Evolution of Lisp - Gabriel and Steele 1993. The following quote is taken from chapter 3.1 (*):
Almost since the beginning, Lisp has used the symbol nil as the distinguished object that indicates the end of a list (and which is therefore itself the empty list); this same object also serves as the false value returned by predicates. McCarthy has commented that these decisions were made “rather lightheartedly” and “later proved unfortunate.”
(*) a link to this book can be found on this page: http://www.newlisp.org/index.cgi?page=Links

Re: Why () not evaluate to nil?

Posted: Sun Feb 27, 2011 11:06 pm
by cormullion
In Clojure, nil and the empty list ("()") are not the same. Scheme doesn't have a value named nil. So weirdness is relative :)

Re: Why () not evaluate to nil?

Posted: Mon Feb 28, 2011 5:37 pm
by anemo
Guess it was just a surprise for me :D

And a bigger one than I would have thought with () evaluating to nil being considered an unfortunate decision.