# \#self-reference

**URL:** https://discourse.julialang.org/tag/self-reference/401.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [How is \`deepcopy\` so clever regarding aliasing and self-reference?](https://discourse.julialang.org/t/how-is-deepcopy-so-clever-regarding-aliasing-and-self-reference/113235)

<div class="topic-metadata">

**Author:** [@iago-lito](https://discourse.julialang.org/u/iago-lito)\
**Replies:** 4\
**Last updated:** [April 19, 2024, 1:43pm UTC](https://discourse.julialang.org/t/how-is-deepcopy-so-clever-regarding-aliasing-and-self-reference/113235 "2024-04-19T13:43:10Z")

</div>

I find this behaviour very fortunate, but also black magic: a = \[5\] u = \[a, a, a\] v = deepcopy(u) v\[1\]\[1\] = 8 v # \[\[8\], \[8\], \[8\]\] # My naive 'deepcopy' would have produced \[\[8\], \[5\], \[5\]\] instead. I expected deepcopy …

---

## [Parametrizing a self-referential function field](https://discourse.julialang.org/t/parametrizing-a-self-referential-function-field/44538)

<div class="topic-metadata">

**Author:** [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Replies:** 4\
**Last updated:** [August 8, 2020, 11:46am UTC](https://discourse.julialang.org/t/parametrizing-a-self-referential-function-field/44538 "2020-08-08T11:46:20Z")

</div>

My struct changes its input function to automatically get the struct as an argument. This works if I don’t type the struct, but I have no idea how I can type it. mutable struct CoronaModel{F1} # other fields omitted…

---

## [How to create tree from struct](https://discourse.julialang.org/t/how-to-create-tree-from-struct/39372)

<div class="topic-metadata">

**Author:** [@wiktorkujawa](https://discourse.julialang.org/u/wiktorkujawa)\
**Replies:** 4\
**Last updated:** [May 13, 2020, 9:08am UTC](https://discourse.julialang.org/t/how-to-create-tree-from-struct/39372 "2020-05-13T09:08:46Z")

</div>

I want to create tree with struct. Here’s my approach: mutable struct node{T} data::T left::node right::node node(T)= (data=T; left= Nothing; right= Nothing) end root=node(1) root.left=node(2) root.right=node(3…
