difference between copy and copy/deep
[1/4] from: th72::dds::nl at: 25-Jun-2005 14:48
Hello List,
Can someone give me an example of the diffrence between copy and copy/deep?
I can't find any differences...
Thanks.
Tim
[2/4] from: greggirwin::mindspring::com at: 25-Jun-2005 8:48
Hi Tim,
TH> Can someone give me an example of the diffrence between copy and copy/deep?
TH> I can't find any differences...
The /deep refinement tells REBOL to make copies of all nested series,
as well as the top level one.
If we start with this:
>> a: [[1 2 3] [4 5 6]]
== [[1 2 3] [4 5 6]]
>> b: copy a
== [[1 2 3] [4 5 6]]
>> c: copy/deep a
== [[1 2 3] [4 5 6]]
There is no difference when we change the top level series
>> append c 'xxx
== [[1 2 3] [4 5 6] xxx]
>> a
== [[1 2 3] [4 5 6]]
>> append b 'xxx
== [[1 2 3] [4 5 6] xxx]
>> a
== [[1 2 3] [4 5 6]]
Now, if we change a sub-series, you'll see that copy/deep prevented
them from being changed in the original, while copy did not.
>> append c/1 'yyy
== [1 2 3 yyy]
>> a
== [[1 2 3] [4 5 6]]
>> append b/1 'yyy
== [1 2 3 yyy]
>> a
== [[1 2 3 yyy] [4 5 6]]
-- Gregg
[3/4] from: SunandaDH::aol::com at: 25-Jun-2005 13:37
Tim:
> Can someone give me an example of the diffrence between copy and copy/deep?
> I can't find any differences..
b: copy []
append/only b b
copy b
copy/deep b
Maybe not the best example.....Read Gregg's reply for the definitive answer.
Sunanda
[4/4] from: th72:dds:nl at: 26-Jun-2005 17:30
Hi Gregg,
Thanks for your explanation. I do understand now the difference between
copy and copy/deep. You only see the difference if you change something
in a series and not when you completely replace a series inside a
series. Thanks. Tim
Gregg Irwin wrote: