Why do you think that deepcopy works on SelfReferential without defining deepcopy_internal? Line 8 of deepcopy.jl is: deepcopy(x) = deepcopy_internal(x, ObjectIdDict())
On Tuesday, August 23, 2016 at 10:52:35 AM UTC+2, Chris Stook wrote: > > I created this simple example to try to understand deepcopy_internal. > > type SelfReferential > obj::SelfReferential > > SelfReferential() = (x = new(); x.obj = x) > end > > function deepcopy_internal(sr::SelfReferential, oidd::ObjectIdDict) > # if haskey(oidd,sr) > # return oidd[sr] > # else > new_obj = deepcopy_internal(sr,oidd) > new_sr = sr(new_obj) > oidd[sr] = new_sr > return new_sr > # end > end > > sr = SelfReferential() > deepcopy_sr = deepcopy(sr) > > This works, but deepcopy works on SelfReferential without defining > deepcopy_internal, so this isn't a good > example. > > How should this be modified so deepcopy_internal is required? > > Are the commented out lines of code necessary? > > Thanks, > Chris > >
