Subject: predicates and generalized booleans
From: Erik Naggum <>
Date: 1997/04/08
Newsgroups: comp.lang.lisp
Message-ID: <>

I'm sorry to interrupt the Java discussions with a simple Lisp question.

I needed a form that is t if a segment of an input string is empty, the
expression read from the substring if it is a complete expression, or the
bounding positions of the substring if end of file was encountered in
reading it.  I had this in mind (slightly simplified):

    (or (= start end)
        (read-from-string buffer nil nil
	   :start start
	   :end end)
        (cons start end))

but then I remembered something about generalized booleans, and looked up
`=' in ANSI X3.226.  it seems that an implementation is free to return any
non-nil value as the result of comparing two equal numbers.  now, this is
probably an academic issue, since no Common Lisp implementation I have ever
seen returns anything but t for true in such cases, so my question is not
what to do in practice, but why so many predicates were specified to return
a "generalized boolean" instead of just a "boolean".

the relevant glossary entry for "t" reads:

    t ... 1. ...  b. the canonical generalized boolean representing
    true. (Although any object other than nil is considered true as a
    generalized boolean, t is generally used when there is no special
    reason to prefer one such object over another.) ...

clearly, `=' and the like do not have any such special reasons, so what
motivated the use of "generalized boolean" instead of "boolean"?

I'm no longer young enough to know everything.