Generic swap

func swap(Ref a, Ref b) {
    var tmp = *a
    *a = *b
    *b = tmp
}

or:

func swap(Ref a, Ref b) {
    (*a, *b) = (*b, *a)
}

or:

func swap(Ref a, Ref b) {
    [*a, *b] » (b, a)
}

The swap functions must be called with variable references.

var (x, y) = (1, 2)
swap(\x, \y)