* yes, to make inheritance easier (vars of different types (ancestors, 
descendants) are of the same size, size of a pointer)
  * no copying when passing - good for large objects, or when transmitted or 
used as arguments often
  * you can use arrays/seqs of different-sized (disregarding inheritance) 
ref-objects - really arrays of pointers
  * you can even store them in collections of arbitrary references (of any, 
incl. non-object, type) or just pointer-sized values



And the like, just examples.

Ref-objects are allocated on heap, that is they require memory allocation, so 
when you don't have reasons to use them (in simple cases esp.), better to use 
value objects, which in Nim are no-overhead (say, a no-inheritance object 
containing 2 integers is of the size 2 integers, which are located directly in 
it and are passed to procs on stack).

Reply via email to