# Which copy function should I overload?

**URL:** <https://discourse.julialang.org/t/which-copy-function-should-i-overload/129595>\
**Category:** General Usage\
**Tags:** copy, deepcopy\
**Created:** [June 3, 2025, 10:25am UTC](https://discourse.julialang.org/t/which-copy-function-should-i-overload/129595 "2025-06-03T10:25:53Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![TimG](https://avatars.discourse-cdn.com/v4/letter/t/82dd89/32.png) [@TimG](https://discourse.julialang.org/u/TimG)\
**Post date:** [June 3, 2025, 5:36pm UTC](https://discourse.julialang.org/t/which-copy-function-should-i-overload/129595/3 "2025-06-03T17:36:22Z")

</div>

I [recently](https://discourse.julialang.org/t/reliably-make-a-clean-copy-of-an-xml-node/129495/5) defined a `copy` method for an XML.jl `Node`. I thought I was doing the right thing to avoid `deepcopy`.

`Node`s in XML.jl are immutable but they may contain some mutable elements, one of which may be a set of nested vectors of child `Nodes`. To copy a `Node`, it is also necessary to copy all it’s children. So my `copy` is not shallow.

I am working with XML to manipulate Excel `.xlsx` files. I have a library of `Node`s in a `Dict` to provide a set of common Excel features and these each includes nested child `Node`s. To add one to an `xlsx` file, I copy the `Node` from the library and then insert it into the internal XML structure of the `xlsx` file.

I can call the function I use to make a duplicate of the `Node` in the library anything I want, but functionally, I am making a copy. Is this to be frowned upon? And if so, what should I do instead? Just rename the function?

---

_[View the full topic](https://discourse.julialang.org/t/which-copy-function-should-i-overload/129595)._
