From: Johnny
Subject: code in hyperspec
Date: 
Message-ID: <2a56f6a3.0407221811.5c5f2892@posting.google.com>
Example under "assoc" :


 (setq values '((x . 100) (y . 200) (z . 50))) =>  ((X . 100) (Y .
200) (Z . 50))
 (assoc 'y values) =>  (Y . 200)
 (rplacd (assoc 'y values) 201) =>  (Y . 201)


 In the first line, "values" is assigned a literal expression, and in
the last line, that literal expression is modified. Is this asking for
trouble?

From: Kenny Tilton
Subject: Re: code in hyperspec
Date: 
Message-ID: <q20Mc.97497$a92.50872@twister.nyc.rr.com>
Johnny wrote:

> Example under "assoc" :
> 
> 
>  (setq values '((x . 100) (y . 200) (z . 50))) =>  ((X . 100) (Y .
> 200) (Z . 50))
>  (assoc 'y values) =>  (Y . 200)
>  (rplacd (assoc 'y values) 201) =>  (Y . 201)
> 
> 
>  In the first line, "values" is assigned a literal expression, and in
> the last line, that literal expression is modified. Is this asking for
> trouble?

Yeah, I have noticed that myself. It's a disease. Every introductory 
text does the same (cheat a little to make examples more succinct), 
which is why a rite of passage for Lisp newbies is to emulate that 
example and be excoriated on c.l.l. for modifying a literal. :)

kt

-- 
Cells? Cello? Celtik?: http://www.common-lisp.net/project/cells/
Why Lisp? http://alu.cliki.net/RtL%20Highlight%20Film
From: David Steuber
Subject: Re: code in hyperspec
Date: 
Message-ID: <87vfgcdcn1.fsf@david-steuber.com>
Kenny Tilton <·······@nyc.rr.com> writes:

> Johnny wrote:
> 
> > Example under "assoc" :
> >  (setq values '((x . 100) (y . 200) (z . 50))) =>  ((X . 100) (Y .
> > 200) (Z . 50))
> >  (assoc 'y values) =>  (Y . 200)
> >  (rplacd (assoc 'y values) 201) =>  (Y . 201)
> >  In the first line, "values" is assigned a literal expression, and in
> > the last line, that literal expression is modified. Is this asking for
> > trouble?
> 
> Yeah, I have noticed that myself. It's a disease. Every introductory
> text does the same (cheat a little to make examples more succinct),
> which is why a rite of passage for Lisp newbies is to emulate that
> example and be excoriated on c.l.l. for modifying a literal. :)

I think even the CLHS talks about the evil of doing that.

Somehow I think the problem is caused by too much literal mindedness.
Is there such a thing as metaphoric programming?

-- 
An ideal world is left as an excercise to the reader.
   --- Paul Graham, On Lisp 8.1
From: Pascal Costanza
Subject: Re: code in hyperspec
Date: 
Message-ID: <cdqmnb$8ok$1@newsreader2.netcologne.de>
Johnny wrote:

> Example under "assoc" :
> 
>  (setq values '((x . 100) (y . 200) (z . 50))) =>  ((X . 100) (Y .
> 200) (Z . 50))
>  (assoc 'y values) =>  (Y . 200)
>  (rplacd (assoc 'y values) 201) =>  (Y . 201)
> 
> In the first line, "values" is assigned a literal expression, and in
> the last line, that literal expression is modified. Is this asking for
> trouble?

Yes, but you should keep Section 1.4.3 in mind where they say that 
"subsections whose names begin with the words ``Note'' or ``Notes'' or 
``Example'' or ``Examples'' are provided for illustration purposes only, 
and are not considered part of the standard."


Pascal

-- 
Tyler: "How's that working out for you?"
Jack: "Great."
Tyler: "Keep it up, then."