Your problem is the type system and that there is different [procedural 
types](https://nim-lang.org/docs/manual.html#types-procedural-type).

A normal proc in nim always is of type `nimcall`. A normal **unnamed** proc 
(like you have when you use it as a type to store it in `TestOptions`) is 
always of type `closure` so you can have an environment.

You have 2 options, either:
    

  1. you explicitly tell your Callback type that it stores a proc of type 
`nimcall` (which you should do if you **don 't** access global variables in 
that proc) or



  2. you define your `show` proc as an unnamed proc that you assign to a show 
variable`closure` (which you should do if you _do_ plan on accessing global 
variables).



For 1 simply change your callback definition: ` Callback = Option[proc(name: 
string, length: int) {.nimcall.}]`

For 2 simply change your proc definition:
    
    
    const show =proc(name: string, length: int) {.closure.} =
      echo "Callback executed: ", name, " is ", length, " inches long"
    
    
    Run

Reply via email to