Fix #20
See #20 for context: > allows the procedure to be stored in a variable and called correctly (even with default parameters). > As said by Araq on IRC: >> 'procvar' doesn't do much [...] it's just another check for semantic checking. codegen is not affected.
This commit is contained in:
parent
9fcb01c621
commit
4ed8b34d0f
1 changed files with 2 additions and 2 deletions
|
|
@ -20,10 +20,10 @@ $ nim c -r filterclosure.nim
|
||||||
@[64, 128, 256]
|
@[64, 128, 256]
|
||||||
```
|
```
|
||||||
|
|
||||||
Existing procedures can also be passed as functions, but only if they are annotated with the `{.procvar.}` pragma.
|
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.
|
||||||
|
|
||||||
``` nimrod
|
``` nimrod
|
||||||
proc greaterThan32(x: int): bool {.procvar.} = x > 32
|
proc greaterThan32(x: int): bool {.procvar.} = x > 32
|
||||||
|
|
||||||
echo powersOfTwo.filter(greaterThan32)
|
echo powersOfTwo.filter(greaterThan32)
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue