Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: difference between copy and copy/deep

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