[EMAIL PROTECTED] wrote:
> 
> 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>
> 

I've been following this thread with great interest, and finally
realized something that (AFAIK) hasn't been addressed.  It seems to
me that much of the confusion arises from assuming a two-level model
of a situation that actually has three levels.

It took me a while to realize that "a series" is not a simple thing,
but an underlying collection I'll call a "sequence", along with a
position indicator.  Thus we don't have:

    variable world     sequence world
    --------------     --------------
    fie ---------------+
                       |
                       v
                       [1 2 3 4 5 6 7 8 9]
                       ^
                       |
    foe ---------------+

but rather we have:

    variable world    series world    sequence world
    --------------    ------------    --------------

    fie -------------> (*)
                        |
                        +--------------+
                                       |
                                       v
                                      [1 2 3 4 5 6 7 8 9]
                                           ^
                                           |
                        +------------------+
                        |
    foe -------------> (*)

in which some operations (e.g. 'length? 'tail? and 'next) operate in
series world (in which fie and foe are NOT entangled) and other
operations (e.g., 'clear and 'insert) operate in SEQUENCE world (to
which the series world entities BOTH refer).

Thus

    >> fie: [1 2 3 4 5 6 7 8 9]
    == [1 2 3 4 5 6 7 8 9]
    >> foe: next next fie
    == [3 4 5 6 7 8 9]
    >> length? fie
    == 9
    >> length? foe
    == 7

leaves the impression that 'fie and 'foe are different, but

    >> head fie
    == [1 2 3 4 5 6 7 8 9]
    >> head foe
    == [1 2 3 4 5 6 7 8 9]

shows that they are somehow entangled, and

    >> insert fie 100
    == [1 2 3 4 5 6 7 8 9]
    >> foe
    == [2 3 4 5 6 7 8 9]
    >> length? fie
    == 10
    >> length? foe
    == 8

shows unexpected (unless one really understands the implementation)
side effects.  Maybe I'm just dense, but this was VERY unclear to me
until the third-level "sequence" concept emerged.  This leaves me
with two questions:

1)  Is the above three-level concept an accurate model?

2)  Would newcomers find REBOL series behaviors less cryptic if
    explained this way?

-jn-

(Not trying to say what it SHOULD be doing, just trying to make sure
I understand what it IS doing...)

Reply via email to