[REBOL] Re: The reaseon for having SERIES?
From: fuka:fuxoft:cz at: 5-Jan-2003 15:17
Yes, I understand this, but I don't understand why there is ISSUE type
in Rebol at all. It seems tu me that I can simply use STRING instead of
ISSUE in all possible circumstances and functionality would be the same.
Joel Neely wrote:
> Hi, Frantisek,
>
> 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:
>
> NUMBER!
> INTEGER!
> DECIMAL!
>
> 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
> pseudo-type.
>
> 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:
>
> SERIES!
> ANY-STRING!
> STRING!
> FILE!
> URL!
> EMAIL!
> ...
> ANY-BLOCK!
> BLOCK!
> LIST!
> HASH!
>
> 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
> every case:
>
> 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!
>
> -jn-
--
Frantisek Fuka
(yes, that IS my real name)
(and it's pronounced "Fran-tjee-shek Foo-kah")
----------------------------------------------------
My E-mail: [fuka--fuxoft--cz]
My Homepage: http://www.fuxoft.cz
My ICQ: 2745855