Can someone tell me why (below) (= temp nil) and (=temp null) don't evaluate (blow up)?
I thought that you could compare null to a list to see if it was empty. Isn't (setq temp()) setting
temp to an empty list?
[12]> (setq temp ())
NIL
[13]> temp
NIL
[14]> (= temp nil)
*** - =: NIL is not a NUMBER
The following restarts are available:
USE-VALUE :R1 You may input a value to be used instead.
1. Break [15]> (= temp null)
*** - EVAL: variable NULL has no value
The following restarts are available:
STORE-VALUE :R1 You may input a new value for NULL.
USE-VALUE :R2 You may input a value to be used instead of NULL.
USE-VALUE :R3 You may input a value to be used instead.
2. Break [16]>
Thanks
Jeff Kish <·········@earthlink.net> wrote in message news:<····························@4ax.com>...
> Can someone tell me why (below) (= temp nil) and (=temp null) don't evaluate (blow up)?
For one thing, the = function is a strictly numeric comparison. You
can only use it on numbers, not on symbols, lists or other objects.
That's why you got the error ``NIL is not a number''.
You want (eq temp nil) or (null temp).
The symbol NULL is the name of a predicate function that tests whether
its argument is NIL, as in the second example above.
The symbol NULL is also the name of NIL's type: NIL is the only value
in the domain of the NULL type. Try evaluating the expression (type-of
nil).
NULL is also the name of the CLOS class of the NIL object. Try
evaluating (class-name (class-of nil)).
But other than that, the NULL symbol is not special. Unlike NIL, T and
symbols in the keyword package, it has no special semantics under
evaluation, and is expected to name a variable. That's why you got the
error ``variable NULL has no value''.
You have to read and interpret those error messages carefully!
Jeff Kish <·········@earthlink.net> writes:
> Can someone tell me why (below) (= temp nil) and (=temp null) don't evaluate (blow up)?
> I thought that you could compare null to a list to see if it was empty. Isn't (setq temp()) setting
> temp to an empty list?
= is for numbers only
Use EQL for testing identity.
NULL is the same as (EQL xxx NIL)
--
~jrm
Joe Marshall <·············@comcast.net> writes:
> Jeff Kish <·········@earthlink.net> writes:
>
> > Can someone tell me why (below) (= temp nil) and (=temp null) don't evaluate (blow up)?
> > I thought that you could compare null to a list to see if it was empty. Isn't (setq temp()) setting
> > temp to an empty list?
>
> = is for numbers only
>
> Use EQL for testing identity.
>
> NULL is the same as (EQL xxx NIL)
Which means that NULL is a function [ the value slot of the
COMMON-LISP:NULL symbol not defined to contain anything, ie:
(NOT (BOUNDP 'COMMON-LISP:NULL))
], and that the definition of the NULL function is equivalent to:
(lambda (x) (eql x nil))
.
--
__Pascal_Bourguignon__ http://www.informatimago.com/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Living free in Alaska or in Siberia, a grizzli's life expectancy is 35 years,
but no more than 8 years in captivity. http://www.theadvocates.org/
Jeff Kish <·········@earthlink.net> writes:
> Can someone tell me why (below) (= temp nil) and (=temp null) don't evaluate (blow up)?
> I thought that you could compare null to a list to see if it was empty. Isn't (setq temp()) setting
> temp to an empty list?
= is for numbers only
Use EQL for testing identity.
NULL is the same as (EQV xxx NIL)
--
~jrm
Joe Marshall <·············@comcast.net> writes:
> Jeff Kish <·········@earthlink.net> writes:
>
>> Can someone tell me why (below) (= temp nil) and (=temp null) don't evaluate (blow up)?
>> I thought that you could compare null to a list to see if it was empty. Isn't (setq temp()) setting
>> temp to an empty list?
>
> = is for numbers only
>
> Use EQL for testing identity.
>
> NULL is the same as (EQV xxx NIL)
That's supposed to be EQL.
Since I'm fixing a typo, here are some examples:
> (defvar *temp* '())
> (null *temp*)
t
> (setq *temp* 't)
t
> (null *temp*)
()
--
~jrm