JuliaLang/julia — pull request #1242 by carlobaldassi (2012-08-31 13:20:41+00:00)
Title: RFC: deep_copy proposal

I needed a generic deep_copy function, so I wrote one based on serialization/deserialization which seems to work well:

```
julia> a = {{1,2},{3,4}};

julia> ca = copy(a); # standard shallow copy

julia> dca = deep_copy(a);

jjulia> ca[1][1] === a[1][1] # at depth > 1, only the pointer was copied
true

julia> dca[1][1] === a[1][1] # in this case we have a true copy
false
```

There seem to be very few objects which cannot be copied in this way yet (e.g. regex's):

```
julia> deep_copy(r"tst")
no method write(IOStream,Ptr{None})
in method_missing at base.jl:70
in serialize at serialize.jl:216
in serialize at serialize.jl:226
in deep_copy at operators.jl:138
```

Comments?