chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Set! question


From: Graham Fawcett
Subject: Re: [Chicken-users] Set! question
Date: Sat, 5 May 2007 20:28:58 -0400

On 5/5/07, William Ramsay <address@hidden> wrote:
The colors are kept in a vector.  What I tried was setting a variable
for each color
by referencing it's match in the vector.   This failed because changing
the variable
changed the vector.    I now use vector-copy!, which seems to work.
If I change
the temp vector colors and then cancel out, my original vector is still
what it was.
(This seems to go against what you are saying below.)    Once the user
has the new
colors set I copy the temp vector into the original vector and the
colors are changed.

Just curious, how is a colour represented in your code -- by a symbol
(e.g. 'blue), a number, a string ("green"), etc.?

My guess is that, to change colours, you are using something like
(vector-set! temp-vec index newcolour), right? Following my horrible
building analogy, that would be like altering your copy of the list of
buildings, rather than actually mutating the buildings themselves. You
might, say, remove your house from your own copy of the list, before
blowing the list-members up. It's still on my list, just not on yours.
There's a distinction between mutating the vector (e.g. vector-set! or
vector-copy!) and mutating one or more of its elements (such as
(do-something-to! (vector-ref vec index))). Does that make sense?

I'm not trying to confuse you. :-) Perhaps you could post some code,
and we could discuss a concrete example?

Graham




reply via email to

[Prev in Thread] Current Thread [Next in Thread]