Consider this, Joel. 

A series is a block; a block is a series. 

Blocks can store anything, even other blocks, or nothing. 

Blocks can store code or data.

A block exists in it's own right. The REBOL variables are simply an
(arbitrary) index into the block. The block does not contain a position
indicator. But a variable may refer to a position in a block. 

It might be helpful for you to think of a series variable as a record 

myBlock: pointer
myIndex: word

where myBlock is a pointer to the block and myIndex is the variable's
position in the series (the nth element).

I don't believe the blocks are "aware" of the variables. The block
exists independently of the variables.

The series operations use the variable to locate the block and
(sometimes) to determine where the operation should begin.

How about this: FIE and FOE are bookmarks. when you ask about FIE and
FOE's length, you are told the number of pages from each to the end of
the book. (Yeah, that's it, that's the simile ... bookmarks ...)

If you want to know the length of the book, ask "LENGTH? HEAD FIE" and
REBOL will flip back to the cover and count from there (but leave your
bookmark undisturbed).

Without using the HEAD or TAIL functions, the operations are relative
to the variable (or bookmark). (The notable exception being APPEND.)

In some ways, the "problems" with series may be "Advanced Users
Syndrome". In many other languages, in order to get something as useful
as a block, we have to assign the block to a specific variable, and
then use a second variable to transverse the block. 

In REBOL, the one variable provides both features. It locates the
block, and allows you to transverse the block. But REBOL also allows
(and even encourages) you to set multiple variables to the same block,
if that's useful to you. 

It's new wine, for sure.

HTH.

-Ted.

*********** REPLY SEPARATOR  ***********

On 12/13/1999 at 5:23 PM [EMAIL PROTECTED] wrote:

[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