let x: ptr T = addr(y)
# vs
let x: ref T = newRef(y)
You can't get a ref of a variable, because it's unsafe, and ref's are supposed to be safe to use.
Let's say you allocate an object on the stack (when you type let y: SomeThing), then hypothetically get a reference of it (let x = getRef(y)), then pass it to a procedure, that procedure is now allowed to store that reference in a global variable or another object. Later your variable y goes out of scope, but you can still have references to it, which are now invalid.
You can of course copy the content of y into a new allocated ref. E.g.
var x: ref T
new(x)
x[] = y
If you want to be able to do this in one procedure it should be possible to write one.
See: http://nim-lang.org/tut1.html#reference-and-pointer-types
str = "abc"
refStr: ref string
# refStr = ref(str) not possible
I just discovered you can
str1: ref String = new(string)
str1[] = "abc"
str2: ref string = str1