[plt-scheme] Why isn't the car of a list of symbols a symbol?

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Thu Jul 9 15:52:21 EDT 2009

On Thu, Jul 9, 2009 at 3:30 PM, Brent Saunders<bsaunders at otxresearch.com> wrote:
> This doesn't make sense.
>
>> (define foo '('yes 'no))

This is equivalent to:

(define foo (list (list 'quote 'yes) (list 'quote 'no)))

>> (symbol? (first foo))
> #f
>
> However,
>
>> (define foo `(,'yes ,'no))

And this is equivalent to:

(define foo (list 'yes 'no))

>> (symbol? (first foo))
> True

The upshot is that the apostrophe followed by expression E means
(quote E).  So if you put an apostrophe inside another apostrophe, you
get (quote (quote E)), which is not what you wanted.  You probably
want something like this:

(define foo '(yes no))

You only need one apostrophe, and the result is equivalent to:

(define foo (list 'yes 'no))

I hope this helps.

--Carl


Posted on the users mailing list.