type
Coord = ref object of RootObj
x,y,z:float
Pt* = ref object of Coord
Tmp = ref object of RootObj
tag:int
point:ref Pt
let a = Pt(x:1.0, y:3.0,z:2.0)
let d = Tmp(tag: 4, point: a ) #<<<< This is what I am interested in
echo repr d
where I got:
/tmp/ex01.nim(14, 26) Error: type mismatch: got <Pt> but expected 'ref Pt'
How do I pass a reference?
type
Coord = ref object of RootObj
x,y,z:float
Pt* = ref object of Coord
Tmp = ref object of RootObj
tag:int
point:Pt
let a = Pt(x:1.0, y:3.0,z:2.0)
let b = a
echo repr b
et d = Tmp(tag: 4, point: b )
echo repr d
d.point.x = 2.0
echo repr d
echo repr b
This seems to work.