« Home » « Learn » « Download » « Github »

logo

Cello High Level C

Examples

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 */

Collections

var i0 = new(Int, $I(100));
var i1 = new(Int, $I(200));
var x = new(Array, Ref, i0, i1);

print(deref(get(x, $I(0)))); /* 100 */
del(x); /* Contents of `x` still alive */

Ref


Shared Pointer

The Ref type is a basic wrapper around a C pointer. It can be used as a type argument to collections to allow them to store generic types. It may also be useful in various circumstances where another level of indirection or mutability is required.

Definition

struct Ref {
  var val;
};

Derives

Implements


Back