How do you create a reference to a sequence? I can see how you create a pointer to a sequence:
var x: seq[float64] = @[1.0, 2, 3, 4, 5];
var y = x.addr;
But have no idea how to create ref seq[float64], or is it only possible to create a ptr seq[float] while the ref keyword is only really used when defining objects?
Thanks in advance.
@b3liever post shows you how to dereference a ref, not a seq
i.e. if it wasn't clear
proc assignToRef[T](x: T): ref T =
new result # allocate the ref object, any type works
result[] = x # assign it x
let y = assignToRef(@[1.0, 2, 3, 4, 5])
would be a builtin for transforming something to ref,
Have you been able to read
http://ssalewski.de/nimprogramming.html#_references_and_pointers
If so, what may I improve?