:sig
function clone(value : string) string
function clone(value : dval) dval
function clone(value : [T]) [T]
function clone(value : struct) struct

:params
value : the value to copy

:returns
A separate copy of the same type.

:content
`clone()` makes a deep copy. For a `dval`, an array, or a struct the result and everything inside it are new objects, and changing one side never shows on the other. A closure or module inside the value is shared, since it has nothing to copy.

Assignment never copies these values, it gives the same object another name. Reach for `clone()` when you want to change a value without changing what you got it from.

:example capy render
struct Point {
    x : s64
    tags : dval
}

var source := Point(1, { a: 1 })
var copy := clone(source)
copy.x = 2
copy.tags.a = 2
var list := [1, 2, 3]
var list_copy := clone(list)
list_copy[0] = 9
print(source.x, " ", source.tags.a, " ", copy.x, " ", copy.tags.a, " ", list[0], " ", list_copy[0], "\n")

:output
1 1 2 2 1 9

:see-group
dval-access

:see
length
set
