Thank you very much @mratsim! :-D This has cleared up a lot of my questions.
It's always fascination how smart compilers can be about reading code and
optimizing it. A huge amount of work has obviously been put into them.
One more question about sink inference: Is it infered once per proc or is it
done once for every call to the proc? ie. it creates separate signatures for
the proc depending on if the argument is sink-able or not. For example:
proc customAdd(s: seq[SomeType], newElement: SomeType) =
s.add newElement
Run
Here `newElement` could be sink-able sometimes, but sometimes not. Does the
compiler see that it _could_ be sink-able, and adds the `sink` parameter? Or
does it create a new overloaded proc with the `sink` parameter as you showed in
your example?