I am creating a type which holds a procedure as one of its fields. When I attempt to compile the file, it provides me with the error 'CommandC' is not a concrete type
.
The problematic snippet is seen below.
type
CommandC = object
tocall: proc (info: CommandC, vrs: SharedTable)
arguments: seq[seq[string]]
subcommands: seq[CommandC]
CommandP = object
cat: string
tocall: proc (info: CommandC, vrs: SharedTable) # This line raises an error during compilation
arguments: seq[string]
textdata: string
I am new to Nim [transitioning from Python for larger projects] and for the life of me cannot figure out what this actually means, or how to fix it. This is likely plain old incompetence on my part.
[I am also new to using Stack Overflow and so if my question is not up to standards then that's my bad and I apologize]
I guess you have found it yourself already. But in case that it was not that obvious, you may understand that Nim is not Python, but a statically typed, compiled language. An unspecified data type like SharedTable can not exist. A table (map) is a mapping from one type to another type, so something like SharedTable[string, int] makes more sense, and the code below compiles for me:
import std/sharedtables
type
CommandC = object
tocall: proc (info: CommandC, vrs: SharedTable[string, int])
arguments: seq[seq[string]]
subcommands: seq[CommandC]
CommandP = object
cat: string
tocall: proc (info: CommandC, vrs: SharedTable[string, int]) # This line raises an error during compilation
arguments: seq[string]
textdata: string