Russell writes:

>> REBOL's clear doesn't clear the stored data, it "disconnects" 'list ...
from it and eventually the garbage collector reclaims the unused memory where
the data is stored.

I don't think so. REBOL's CLEAR directly affects the data that 'list is
"connected" to, and doesn't directly affect the reference of 'list itself.

>> list: [1 2 3 4 5 6 7 8 9]
== [1 2 3 4 5 6 7 8 9]
>> clear at list 6
== []
>> list
== [1 2 3 4 5]

Here's another interesting wrinkle:

>> list: [1 2 3 4 5 6 7 8 9]
== [1 2 3 4 5 6 7 8 9]
>> list2: at list 8
== [8 9]
>> clear at list 6
== []
>> list2
== [8 9]
>> head list2
== [1 2 3 4 5]

'list2 can still find the head of the data it references correctly.

Basically I agree with Russell that:

>> If one insists on establishing two words referring to the same data, then
before one clears one he should 'unset the other.

Except, usually when I have two words referring to the same series, one is at
the head of the data as a reserve, while the second is used to traverse the
data. In this case, of course, the second can be used as a point from which
to clear the data with no danger of corrupting the reference of the first.
Clearing from the head of the data while you've got other pointers farther
along in the series doesn't make sense, which is no doubt why this bug has
taken so long to be discovered.

Eric

Reply via email to