var x: array[5, int]
type ArrRef = ref array[5, int]
var y, z : ArrRef
x = [1, 2, 3, 4, 5]
y = cast[ArrRef](x.addr)
# addr provides a ptr type
# cast to convert ptr to ref
z = y
echo "x ", x, " is ", x.addr.repr
# repr is a lower-level version of the $ to-string operator
echo "y ", y[], " is ", y.addr.repr
# [] is dereference, so c[] --> b
echo "z ", z[], " is ", z.addr.repr
# all [1, 2, 3, 4, 5]
z[4] = 10
echo ""
echo "x ", x, " is ", x.addr.repr
echo "y ", y[], " is ", y.addr.repr
echo "z ", z[], " is ", z.addr.repr
# all [1, 2, 3, 4, 10]
new(z)
# use new() to allocate space for the value to be referenced
z[] = x
z[4] = 20
echo ""
echo "x ", x, " is ", x.addr.repr
echo "y ", y[], " is ", y.addr.repr
echo "z ", z[], " is ", z.addr.repr
# only z is [1, 2, 3, 4, 20]