A named reference can be used to hold a reference to a term, in the same way as a logical variable. Unlike a logical variable, the reference has a name under which it can be looked up. Its value is not a copy, but a reference to the actual Value. This implies that the value behaves logically, i.e. it disappears on backtracking, bindings to the variables inside it are undone on backtracking etc.
Changing the value of a reference is similar to changing an argument of a compound term using setarg/3. The change is undone on backtracking, i.e. the value of the reference reverts to what it was before being changed. A reference that has never been set (or whose settings were all undone by backtracking) has its declared initialization value.
Reference names are visible in the module where they are declared. Furthermore every ECLiPSe engine has its own reference store, meaning that the values are engine/thread-local and cannot be shared.
?- local reference(r, hello). Yes (0.00s cpu) ?- getref(r,X), setref(r,world), getref(r,Y). X = hello Y = world Yes (0.00s cpu) ?- getref(r,X), ( setref(r,world), fail ; getref(r,Y) ). X = hello Y = hello Yes (0.00s cpu)