No matching definitions.

tur/ref

stdlib/ref.tur

heap-allocated mutable reference cell with independent ownership.

Since: Phase B1

defstruct

Ref

(defstruct Ref [value : int])

heap-allocated single-value container with independent ownership.

Since: Phase B1

defopaque

RefHandle

(RefHandle)
defn

ref-new

(ref-new [value : int] :)

allocate a new Ref cell on the heap containing value.

valuethe int64 value to store inside the Ref

A RefHandle (an opaque :int pointer cast) to the new Ref cell.

(def r (ref-new 42))  ; => RefHandle to Ref{42}

Since: Phase B1

defn

ref-get

(ref-get [r : RefHandle] :)

read the value stored in a Ref cell.

ropaque Ref handle returned by ref-new

The int64 value stored inside the Ref.

(ref-get (ref-new 99))  ; => 99

Since: Phase B1

defn

ref-free

(ref-free [r : RefHandle] :)

free the Ref cell (shallow; does not free the contained value).

ropaque Ref handle returned by ref-new

Since: Phase B1

definstance

Clone[Ref]

(definstance Clone [Ref])

deep-clone a Ref struct: allocates a new Ref with an independent copy of the value.

Since: Phase B1