Just to back-up Elan's post:
"The change, insert, remove, and clear functions directly affect the
series provided as the first argument. If you have other variables that
refer to the same series, after the operation they may no longer
reference the same value within the series."
<http://www.rebol.com/users.html#Modifying>
So it is important to remember that the variables point to the nth
element of the series, not to the element itself.
I agree that it would seem convenient to have something like a pointer
to an element, that moved when it moved (without looking it up again),
but I don't see how you could say that in REBOL itself. Perhaps we'll
see that in a future refinement. Or a refined series that allowed for
indexing, record ID's, and other real-life database features
(REBOL/SQL?).
-Ted.
*********** REPLY SEPARATOR ***********
On 12/13/1999 at 9:45 AM [EMAIL PROTECTED] wrote:
Hi Petr,
you wrote:
>->> ref2: find block "D"
>== ["D" "E" "F" "G" "H" "I"]
>
>Now imagine {insert block "1"}:
>->> print ref2
>C D E F G H I
>I can't
>see the logic of operation being right for 'ref2, as we simply
>instructed REBOL to {find "D"}.
We did. Note the past tense. REBOL returned the series at the index at
which D was found. That's also history. ref2 was made a reference to
the
series at that *index* (find returns the series beginning at the index
of
the element it searches!) ref2 continues to be a reference to the block
at
the index D was found. When you change the element at that index, the
change will logically affect the element found at that index by ref2.
If you want ref2 to be a word that accesses the block at the index at
which
the element D happens to be at the time ref2 is used and not at the
time
find was evaluated, then make ref2 something that is updated along with
the
block at the time it is dereferenced:
ref2: func [] [ find block "d" ]
While you may have first found REBOL's behavior confusing in this
respect,
I don't think that REBOL should be held responsible. It just reflects
the
fact that as a newbie you had a hypothesis about what ref2 is and that
hypothesis was imprecise.
Elan