Hi Joel!

You wrote:

>Perhaps I should have addressed my comments to the documentation
>team, rather than the general mailing list.  However, it seemed (and
>still seems) to me that some confusion arises from lumping all of
>these operators together as operating on series values, when they
>are really working at two different levels.  I believe the extra
>level in this model makes it more immediately obvious why
>
>    seriesreference1: next seriesreference1
>
>is "safe" and has no side effects on any other references to the same
>underlying data, while

I think the built-in help is usually pretty clear on this issue:

>> ? next
Returns the series at its next position.
[...]
>> ? insert
Inserts a value into a series and returns the series after the insert.
[...]

There's nothing in the description of NEXT to make you think it modifies the
series, and the description of INSERT makes it clear that the series will be
modified. Also, one section of the draft documentation, sermodify.html, gives
a list of most of the functions that modify series:

>>Modification Functions
>>REBOL offers a number of powerful functions to modify series. Some of these
>>functions described below are:
>>
>>change -- change elements
>>insert -- add elements
>>remove -- remove elements
>>clear -- clear to end
>>reverse -- reverse the order of elements in a series
>>poke -- change element by index position
>>append -- append elements to end
>>replace -- replaces one or all occurrences of element

As far as I know, only SORT is missing from this list, since it has a special
section. So I don't think it's quite fair to say that series operators are
all lumped together.

To tell you the truth, I found your model too abstract to be easily understood
(but then I've never studied the theory of computer languages). Except for
contexts and binding, REBOL is a language that's easily understood at a very
concrete level.

Perhaps what you were saying could be described this way:

Series values have two aspects: a sequence of data, and an index to a
position within that sequence. Any number of indexes may refer to a single
series. When you construct a series, you will get an index to the first
element in the series. An index defines a position within a series from which
you may read data (as with COPY or PICK), or at which you may make a
modification to the series itself (as with INSERT or POKE). You can also use
an index as a point of reference for defining a new index (as with NEXT, AT
or SKIP).

As for "superclasses" like ANY-STRING! (they're called pseudotypes in REBOL),
I was also seriously puzzled, until I began to use them myself. These are
mainly useful as a shorthand for specifying the kind of data a function will
accept. ANY-STRING! is useful, because this covers all series values that are
guaranteed to be composed of character values.

>> type? #issue
== issue!
>> type? first #issue
== char!

So if you write a function that will do something useful with that type of
data and only that type of data, you can do:

any-string-func: func [string [any-string!]][ .... ]

which will guarantee that your function code will only see the right kind of
data, and anyone who attempts to misuse your function will see a useful error
message courtesy of REBOL itself - no extra work on your part!

HTH,
Eric

Reply via email to