tur/typeclass-clone
minimal Clone typeclass stub for definstance sites.
Auto-loaded so ref.tur and other modules can declare (definstance Clone [...] ...) without importing typeclass.tur.
Since: Phase B1
Clone
(defclass Clone [a])
values that can be copied into an independently owned value.
| a | the type to clone |
(clone [x :a] :a)-
a copy of
xthe caller owns. For a primitive this isxitself; for a refcounted handle (String, rc) it is a retain.
(clone 42) ; => 42
Partner of Drop: a captured value that is Clone and Drop is retained when captured and released when the closure env dies.
rc, Ref, String, int, ref, bool, cstr, int8, int16, int32, uint8, uint16, uint32, uint64, float32
Since: Phase B1
Clone[int]
(definstance Clone [int])
Clone instance for int (trivial copy).
Since: Phase B1
Clone[ref]
(definstance Clone [ref])
deep-clone a raw ref<T> (TY_REF): allocates a new int64_t cell and copies the value.
Since: Phase B1