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

Reply via email to