ref
void ref(var self, var item);
Set the object self
to reference the object item
.
deref
var deref(var self);
Get the object referenced by self
.
Usage
var obj0 = $F(1.0), obj1 = $F(2.0);
var r = $(Ref, obj0);
show(r);
show(deref(r)); /* 1.0 */
ref(r, obj1);
show(deref(r)); /* 2.0 */
assign(r, obj0);
show(deref(r)); /* 1.0 */
Reference to other object
The Pointer
class is implemented by types which act as references to other objects. Primarily this class is implemented by Ref
and Box
which provide the two main pointer types in Cello.
struct Pointer {
void (*ref)(var, var);
var (*deref)(var);
};