[REBOL] Re: The reaseon for having SERIES?
From: joel:neely:fedex at: 5-Jan-2003 7:55
Frantisek Fuka wrote:
> What is the reason for having SERIES type in Rebol? I understand
> what the series are for but it seems to me that exact same things
> can be done using normal strings. Having series type when you have
> string seems to me like having negative-integer type when you have
> integer (i.e. redundant)...
To stay with your analogy as best I can, I'd flip the example around;
the REBOL types for numeric data include:
so that, e.g., if you specify something like
nexamp: func [a [number!] ...
then you will be able to evaluate
nexamp 1 ...
as well as
nexamp 3.14 ...
because NUMBER! subsumes both INTEGER! and DECIMAL! into one abstract
Now to your question: the REBOL type system includes (in part) the
SERIES! family, which is the most general type of ordered structure
that REBOL supports. But look at the family tree:
so that any operation that can be applied to a SERIES! value can be
applied to any of the specific types underneath. On the other hand,
there are operations that can be applied to an ANY-STRING! value
(such as UPPERCASE) that make no sense when applied to an ANY-BLOCK!
value. This hierarchy allows us to conveniently/compactly express
exactly what types (or sets of types) we expect to find used in
various settings, without having to provide an exhaustive list in
both-ends: func [s [series!]] [
join copy/part s 1 last s
which behaves as
>> foo: [1 3 5 7 9]
== [1 3 5 7 9]
>> both-ends foo
== [1 9]
is clearly applicable to anything under the SERIES! family tree, and
it's nicer to write it as such than to have to specify
both-ends: func [x [string! file! url! ... block! list! hash!] ...
to make sure that all are included.
Hope this helps!