Why is the null predicate called null, not nullp?
Asked Answered
T

2

8

Basically, the title says it all: In Common Lisp, why is the null predicate called null. not nullp (to conform to other predicates such as evenp or oddp)? Is there a special reason for this?

Tog answered 4/6, 2014 at 12:34 Comment(0)
D
10

First of all, null is not the only one. See atom.

Second, I think these predicates are fundamental ones and thus, very old. I don't think the 'end with p' agreement was introduced from the very beginning of LISP.

Also interesting info on the topic:

By convention, the names of predicates usually end in the letter p (which stands for 'predicate'). Common Lisp uses a uniform convention in hyphenating names of predicates. If the name of the predicate is formed by adding a p to an existing name, such as the name of a data type, a hyphen is placed before the final p if and only if there is a hyphen in the existing name. For example, number begets numberp but standard-char begets standard-char-p. On the other hand, if the name of a predicate is formed by adding a prefixing qualifier to the front of an existing predicate name, the two names are joined with a hyphen and the presence or absence of a hyphen before the final p is not changed. For example, the predicate string-lessp has no hyphen before the p because it is the string version of lessp (a MacLisp function that has been renamed < in Common Lisp). The name string-less-p would incorrectly imply that it is a predicate that tests for a kind of object called a string-less, and the name stringlessp would connote a predicate that tests whether something has no strings (is ``stringless'')!

Source: http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node69.html

Drawee answered 4/6, 2014 at 12:46 Comment(1)
Yup, it's history. Common Lisp was defined to be the common ground between a bunch of not-quite-compatible Lisps. I don't know, but I bet most of them used null to test for nil.Copartner
K
7

The predicate NULL is very old. It's called NULL in Common Lisp in the hope of encouraging the conversion of legacy Lisp code into Common Lisp

Gosh! It appears in the March 1959 version, and possibly earlier, of McCarthy's original memos (see page 3 of the pdf found here: http://dspace.mit.edu/handle/1721.1/6096 ) as one of the three basic predicates.

Amusingly this is before the introduction of car and cdr. Fascinating - in that memo elements in lists are separated by commas.

Komsa answered 8/6, 2014 at 14:13 Comment(1)
Hmm, the pdf file looks like something really ancient. +1 for interesting historical reference.Drawee

© 2022 - 2024 — McMap. All rights reserved.