In C or C++ or in Go it would just be a matter of using a reference operator : f(&x), x being a "plain type".
How does it work in Nim?
Ex: in the example hereunder, how do you pass ob1 to say() (obviously, it is not say(&ob1) or say(addr(ob1)))
type
rob = ref ob
ob = object
key: int
proc say(r : rob) =
echo r.key
var ob1 = ob(key:42)
Thanks @haxscramper.
So basically when planning to code an application in Nim, one has to decide beforehand whether to represent a given object as a "value type" or as a "reference type" and stick consistently with that choice throughout the app (otherwise there is the cost of making copies).
An additional consequence is that this choice is basically dictated for you when you use a third-party library (which returns a given object as a "ref type" or as a "plain type").
In C or C++ or in Go f(&x)
instead of "The C++ rvlaue lifetime disaster" , the conflation between value category and lifetime, we have affine type annotations: sink et al.
one has to decide beforehand whether to represent a given object as... ...choice is basically dictated for you when you use a third-party library..
well, yes. ¯\_(ツ)_/¯ engineering & designing means making decisions.
but type Foo = object; type FooRef = ref Foo; or type BarObj = object; type Bar = ref BarObj is an idiom