Detailed explanation:
type FooFunc = proc(x: int)
echo FooFunc is proc(x: int) {.closure.} # true
proc foo(x: int) = echo "It works OK!!!"
echo foo is proc(x: int) {.nimcall.} # true
# Type of foo proc is different from FooFunc type as FooFunc is closure but
fo
> However, should the compiler not be able to infer the Foofunc signature
> without the user specifying it?
Alas, I agree. It's very annoying to work with high-order functions due to the
extra ceremony.
I just tried `testFoo` like so and it works:
testFoo("Passing optional proc does not work", f = some[Foofunc](foo))
Run
However, should the compiler not be able to infer the _Foofunc_ signature
without the user specifying it?
Add `{.nimcall.}` to `FooFunc` and it should work fine. It's just some
weirdness in how Nim handles procedure types.
Why does passing this optional proc not work or what am I doing wrong?
import options
type FooFunc = proc(x: int)
proc foo(x: int) = echo "It works OK!!!"
proc testFoo(param1: string, f = none(FooFunc)) =
echo "param1 = ", param1
if f.isSome: