Subject: Re: what is false
From: Erik Naggum <>
Date: 10 Dec 2002 23:08:44 +0000
Newsgroups: comp.lang.lisp
Message-ID: <>

* Kent M Pitman
| There as a public review comment when standardizing that came from 
| Boyer (of Boyer/Moore) and John McCarthy, if I recall correctly.
| The committee replied that they should do exactly as you suggest.

  But `eq´ is not guaranteed to return a boolean.  It may seem rather
  silly for it to return anything else, but the specification is very
  clear that it does not, in fact, return `t´ when it means true.  So

(defun same-truth-value (v1 v2)
  (not (not (eq (not v1) (not v2)))))

  will return `t´ when the two are the same truth value.

  Now, the much more important question is why anyone would care what
  the specific "true" value is.  Nobody tests for anything but `nil´,
  anyway, and writing code that tests for any /particular/ true value
  is broken.

  Incidentally, the above function will effectively, since machine
  operations do not return `nil´ and `t´ but some CPU flag, be at
  least one conditional, so a version of `same-truth-value´ that
  returned a generalized boolean could also be written as

(defun same-truth-value (v1 v2)
  (if v1 v2 (not v2)))

  and if a true boolean is necessary, use (and v2 t) instead of v2.
  In natively compiled Common Lisp implementations, this is much more
  efficient, too, but when expressed this way, there is seldom a need
  for a function for it.

  Also note that the standard name for this boolean operator is `eqv´,
  cf `logeqv´ and `boole-eqv´.

Erik Naggum, Oslo, Norway

Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.