According to Part 1 of the Nim Tutorial,
Traced references are declared with the ref keyword, untraced references are declared with the ptr keyword.
and
To allocate a new traced object, the built-in procedure new has to be used.
What happens if you do not use the new proc for a ref type? For example, I have the following code which compiles and runs fine:
type
Node = ref object
name: string
left: Node
right: Node
proc newNode(name:string, left:Node = nil, right:Node=nil): Node =
Node(name:name, left: left, right:right)
let rootNode = newNode("Grandpa")
let childNode1 = newNode("Uncle")
let childNode2 = newNode("Mother")
let grandchild1 = newNode("Sister")
let grandchild2 = newNode("Nimrod")
rootNode.left = childNode1
rootNode.right = childNode2
childNode2.left = grandchild1
childNode2.right = grandchild2
Since I defined my type using ref, but do not allocate a new traced object, is the object in this case untraced?
http://nim-lang.org/docs/manual.html#types-object-construction
"For a ref object type system.new is invoked implicitly."