From: Tri Tuc Cao
Subject: How to recognize a symbol in lisp.
Date: 
Message-ID: <39B59520.10617DE8@asc.corp.mot.com>
--------------9B354CCFC69E9F86D3614054
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi,

Could someone please explain the difference between the following
expressions:

(setq x 'tuc)
(symbolp x)   ; this function call returns t)

(symbolp (car '( 'tuc)))  ; this returns nil

Why do I get different result here?

Please advise,

Thank you,

Tuc




--

-- Tri Tuc Cao, Software Engineer, Electronic Design Automation --
-- Motorola Australia Software Centre - Adelaide, Australia     --
-- Phone: +61 8 8168 3733, Fax: +61 8 8168 3501,      --



--------------9B354CCFC69E9F86D3614054
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi,
<p>Could someone please explain the difference between the following expressions:
<p>(setq x 'tuc)
<br>(symbolp x)&nbsp;&nbsp; ; this function call returns t)
<p>(symbolp (car '( 'tuc)))&nbsp; ; this returns nil
<p>Why do I get different result here?
<p>Please advise,
<p>Thank you,
<p>Tuc
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<pre>--&nbsp;



-- Tri Tuc Cao, Software Engineer, Electronic Design Automation --&nbsp;
-- Motorola Australia Software Centre - Adelaide, Australia&nbsp;&nbsp;&nbsp;&nbsp; --&nbsp;
-- Phone: +61 8 8168 3733, Fax: +61 8 8168 3501,&nbsp;<GMT+9:30>&nbsp;&nbsp;&nbsp;&nbsp; --</pre>
&nbsp;</html>

--------------9B354CCFC69E9F86D3614054--

From: Coby Beck
Subject: Re: How to recognize a symbol in lisp.
Date: 
Message-ID: <k2jt5.55638$47.782917@news.bc.tac.net>
>"Tri Tuc Cao" <·····@asc.corp.mot.com> wrote in message
······················@asc.corp.mot.com...
>Hi,
>Could someone please explain the difference between the following
expressions:
>(setq x 'tuc)
>(symbolp x)   ; this function call returns t)
>(symbolp (car '( 'tuc)))  ; this returns nil
>Why do I get different result here?
>Please advise,
>Thank you,
>Tuc

Ask lisp!  What is being passed to symbolp?
(car '('foo))
==> 'foo

Perhaps you meant:
(car (list 'foo))
==> foo
or:
(car '(foo))
==> foo
(symbolp (car (list 'foo)))
==> t

Coby
From: Kent M Pitman
Subject: Re: How to recognize a symbol in lisp.
Date: 
Message-ID: <sfwitsagm4s.fsf@world.std.com>
"Coby Beck" <·····@mercury.bc.ca> writes:

> >"Tri Tuc Cao" <·····@asc.corp.mot.com> wrote in message
> ······················@asc.corp.mot.com...
> >[...]
> >(setq x 'tuc)
> >(symbolp x)   ; this function call returns t)
> >(symbolp (car '( 'tuc)))  ; this returns nil
> 
> Ask lisp!  What is being passed to symbolp?
> (car '('foo))
> ==> 'foo

More to the point, saying that 'foo is a shorthand for (quote foo)
would make it more apparent.  (car '('foo)) => (quote foo)
That is, it's a list, not an atom of any kind (of which a symbol is one kind).

Another way of saying this is that the notation for a symbol is just its name.
That is, 'tuc is not a symbol but a notation for (quote tuc), where both 
quote and tuc are symbols.  The evaluation rule for (quote anything) is to
just return the anything directly, and so 'anything also returns the anything
directly.

Tri's confusion might be a belief that 'tuc is a symbol notation, and it is
not.  (In Dylan, for example, the notation would be different.)

The quote needs to appear on the outermost part of a literal constant that is
trying to be used in a program, unless that constant self-evaluates.  Most
kinds of data do self-evluaate, but lists and symbols do not, hence the need
for a quote.
From: Thomas A. Russ
Subject: Re: How to recognize a symbol in lisp.
Date: 
Message-ID: <ymin1hlt265.fsf@sevak.isi.edu>
Tri Tuc Cao <·····@asc.corp.mot.com> writes:
> 
> Hi,
> 
> Could someone please explain the difference between the following
> expressions:
> 
> (setq x 'tuc)
> (symbolp x)   ; this function call returns t)
> 
> (symbolp (car '( 'tuc)))  ; this returns nil
> 
> Why do I get different result here?

Because you don't quite understand the QUOTE mechanism in Lisp.

For starters, compare what you get back when you evaluate the following
forms:

  'tuc
  '('tuc)
  '(tuc)
  (car '('tuc))
  (car '(tuc))
  (car (car '('tuc)))

-- 
Thomas A. Russ,  USC/Information Sciences Institute          ···@isi.edu