Re: Is there any eq t test in Common Lisp?
- From: Pascal Costanza <pc@xxxxxxxxx>
- Date: Sat, 27 Jan 2007 20:59:38 +0100
Pascal Bourguignon wrote:
"Kaz Kylheku" <kkylheku@xxxxxxxxx> writes:
On Jan 26, 6:34 am, "Andreas Thiele" <nos...@xxxxxxxxxx> wrote:Hi,This would be just as silly as
I'm just wondering if there is no predefined synonym for
(defun t-p (x) (eq t x))?
#define TRUE 1
#define ISTRUE(X) (X == TRUE)
in C. (See comp.lang.c FAQ's 9.2 and 9.3). Believe it or not, there are
some programmers who do this. (And I'm not talking about the lack of
parentheses in the expansion of X either; I left that bug in just to
make the example a more realistic depiction of real-world stupidity,
which is rarely found in nature as a free element, because it's
Just like the way any non-zero (or non-null) value in C serves as true,
in Common Lisp anything that isn't NIL serves as true. That's how
``generalized booleans'' work in Common Lisp, and therefore comparing a
boolean value to T is a bug.
Indeed, (eq t x) is silly. If you want to know if x is the symbol t, then you should write (eq 't x).
The constant variable t is specified to return the symbol t, (eq t x) and (eq 't x) are guaranteed to behave the same.
It is indeed the case that it can be useful to distinguish between being "just true" and "true with additional information". For example, one case where this pops up in ANSI CL itself is when you want to define methods for shared-initialize and have to distinguish the three cases for its second argument.
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
- Prev by Date: Re: LISP Object Oriented ?
- Next by Date: Re: LISP Object Oriented ?
- Previous by thread: Re: Is there any eq t test in Common Lisp?
- Next by thread: Re: Is there any eq t test in Common Lisp?