working on today AoC's solution I ran into something unexpected (playground):
proc yo(s: var seq[int]) =
let t = s
var u = s
s.add s.len
echo "s: ", s
echo "t: ", t
echo "u: ", u
var s = @[0]
yo s
s: @[0, 1]
t: @[]
u: @[0]
the behaviour of t is a bit unexpected and let and var seem to behave differently when used for a sequence inside a proc. I saw this oldish (2 year) discussion reporting a similar behaviour: https://forum.nim-lang.org/t/3663
For the real context where I met this see (spoiler for AoC): https://pietroppeter.github.io/adventofnim/2020/day11.html
I am still not sure I understand why the different behaviours, can someone clarify?
thanks, I guess it is time for me to switch to Orc 👹! :)
Is there an open issue referring to it (I was not able to find one)? I can make one with the above example if not, just to keep track.
incidentally, I wish we had a single place in the documentation where we are able to find all compile time switches. I always forget them (in the manual there is only one occurence of when defined and one of when not defined). I might be willing to contribute on this if others feel the same (and if it make sense to do that).
I have to say that I have actually started using the trick to search in github repos and it is very useful to discover code usages. For example I was able to found when defined(gcOrc) that is exactly what I need (updated 2020/day11.html).
You're supposed to find/read https://nim-lang.org/docs/nimc.html - it is rather complete.
but in addition it should be searchable in search box + theindex.html or an equivalent index
but it does not mention the specific syntax gcOrc
There is no such "specific syntax", it's a define and you're not supposed to use it. :-)