Hi,
on the "First Class Functions" section of the "Nim by Example" page, it says:
"Existing procedures can also be passed as functions, but only if they are annotated with the {.procvar.} pragma. This is because there may be default parameters, which must be specially handled by the compiler."
It then shows the following example:
proc greaterThan32(x: int): bool {.procvar.} = x > 32
echo powersOfTwo.filter(greaterThan32)
However, removing the "{.procvar.}" pragma the example still works the same. What gives? I also do not really understand the explanation above (because there may be default parameters...).
I see, thanks! So this only matters for "public" (or whatever they are called) procedures, right?
I think this detail should be mentioned on the "nim by example" page. However I don't feel qualified to send a pull request with a proper edit.
So this only matters for "public" (or whatever they are called) procedures, right?
Turns out so.
should be mentioned on the "nim by example" page
"Nim by example" is likely not considered to be an exhaustive Nim guide, but a quick overview of basic language features, so that people can see Nim in action before learning it. Nim's manual is the easiest and fastest way to learn Nim more in detail, it exists already, is good written and very easy to learn.