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

Reply via email to