Search code examples
assignseqshallow-copynim-lang

Does seq assignment create a new seq copy?


Given tow seqs, a and b, declared like this:

var
  a = @[1, 2, 3]
  b = @[4, 5, 6]

will a = b create a new seq copying everything from b to a or, reuse a? I have problems specially regarding to shallowCopy. I cannot tell what are they doing different.


Solution

  • The short answer is mostly yes.

    The long answer is that sequence assignment is handled by the procs, appearing in the assign module, which is part of the system module. You can search this file for tySequence to see the relevant code.