Value types have a good advantage, but the problem is, that when you make them
too big, they could overflow the stack (iirc 2MB on Windows). But you should
use value type arguments, because a ref type can always be converted to a value
type with the `[]` operator.
proc foo1(arg: Matrix): Matrix
var matref1, matref2: ref Matrix
matref2[] = foo1(matref1[])
The other direction is not as easy. The only problem is that the result will be
a new allocation, no matter if you use ref types or not. So I suggest to also
provide an api that has result arguments
proc foo1(dst: var Matrix, arg: Matrix): void
proc foo1(arg: Matrix): Matrix =
result.foo1(arg)
This allows to reuse temporary matrices more efficiently.
proc foo2(arg: ref Matrix):