[REBOL] Re: TUPLE! DATA-MODEL & OTHER VALUES
From: holger:rebol at: 12-Jun-2001 10:50
On Tue, Jun 12, 2001 at 01:03:14PM -0400, [Robbo1Mark--aol--com] wrote:
> Holger,
>
> Are you saying that REBOL values "can't" be contained in 96 bits or that they "Aren't"
contained within 96 bits.
What I am saying is that you probably should not speculate about such details, because
these things are not only subject to change but can (and do) also vary by platform. Consider
64-bit CPUs, for example. In any case, whether or not a datatype behaves like a series
is not determined by the exact number of bits it requires. That kind of reverse engineering
attempt simply does not help to explain or understand the issue discussed in this thread.
What IS safe to say is:
Simple
types (integer, decimal, time etc.) only take up a small amount of memory and
have "copy" semantics.
More complex types, in particular those that have a variable size (series, object,
function) or complicated underlying data structures (port), but also some fixed-size
types which are quite large (e.g. bitset) always consist of two parts: the "value"
part and the "data" part. The "value" part is unique for each value and conceptually
references (points to) the "data" part. The "data" part is what is shared by several
values and is subject to garbage collection. For a series, e.g., the value part contains
the index, and the data part contains everything else, i.e. the series contents, its
length etc.
What started this discussion was the behavior of the tuple! datatype. In REBOL a
tuple! value is considered "simple". That's why its length is limited and why there
is no underlying "data" that can be changed. A tuple! is not a series!, even though
it is a linear sequence of items, like a series!, and supports some of the same syntax.
Look at the difference:
Series:
a: [1 2 3]
b: a
a/1: 0 ;Changes the data shared by 'a and 'b.
a
== [0 2 3]
b
== [0 2 3]
Tuple:
a: 1.2.3
b: a
a/1: 0 ;Changes 'a only. 'a and 'b do not share data.
a
== 0.2.3
b
== 1.2.3
To see that the index of a series is not shared among different values referencing
the same series, try:
a: [1 2 3]
b: a
a: next a
a
== [2 3]
b
== [1 2 3]
--
Holger Kruse
[holger--rebol--com]