I'm having a hard time finding information about do blocks in the Nim Manual. The only place I can see reference to this is in macro examples coupled with quote.
Can somebody point me to a full description of do block behavior?
Weird. I could've sworn the do notation was explained in the Anonymous Procs section of the manual, but it actually isn't.
In any case, you can find a prime example here in the algorithm module.
It's a way to pass an argument as a block for example
foo(a, b: int) =
echo "1st arg: ", a
echo "2nd arg: ", b
foo(1+1, 2+2)
echo "##############"
foo(1+1) do:
2+2
echo "##############"
proc bar(a, b, c: int) =
echo "1st arg: ", a
echo "2nd arg: ", b
echo "3rd arg: ", c
bar(1+1) do:
2+2
do:
3+3
Returns:
1st arg: 2
2nd arg: 4
##############
1st arg: 2
2nd arg: 4
##############
1st arg: 2
2nd arg: 4
3rd arg: 6
It migrated to "experimental", whose content seems orphaned :-/ as in not searchable from the main index.
https://nim-lang.org/docs/manual_experimental.html#do-notation