Passing an optional proc is not working

2024-06-19 Thread demotomohiro
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

Passing an optional proc is not working

2024-06-19 Thread mratsim
> 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.

Passing an optional proc is not working

2024-06-19 Thread TKD
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?

Passing an optional proc is not working

2024-06-19 Thread PMunch
Add `{.nimcall.}` to `FooFunc` and it should work fine. It's just some weirdness in how Nim handles procedure types.

Passing an optional proc is not working

2024-06-19 Thread TKD
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: