Are these two definitions equivalent?
type
PersonObj = object
name: string
age: int
PersonRef = ref PersonObj
type
PersonObj = ref object
name: string
age: int
In the latter should PersonObj be simply called Person?
They are not equivalent as the first PersonObj
is not ref
, while the second is. To be equivalent the second definition should read as
type PersonRef = ref object
name: string
age: int
Now Obj
or Ref
suffixes is your own decision. Usually the suffixes are not used if the type is intended to be always used either as value type or a ref type, so it would be just:
type Person = ref object
name: string
age int