Nim Compiler Version 0.13.0 (2016-01-19) [Windows: i386]
How would I store a reference to a procedure in a tuple:
Job = tuple[every:int, timescale:string, timestr:string, jobfunc:proc]
proc run(job: Job, jobfunc: proc): Job =
result = job
result.jobfunc = addr jobfunc
In the run proc jobfunc: proc gets accepted. In the tuple I get:
Error: 'proc' is not a concrete type.
So whats the type of proc?
[edit]
My ultimate goal is to pass a function with arbitrary parameters to run
.
Atm I've managed to work around this by using an seq[string]
but maybe one knows a more generic way.
type
Job = tuple[every:int, timescale:string, timestr:string, jobfunc: proc(args:seq[string]) {.gcsafe, locks: 0.}]
proc run(job: Job, jobfunc: proc,args:seq[string]= @[""] ): Job =
# ...
discard
proc myfunc(args:seq[string]) =
echo "hello from myfunc ", args
discard
schedule every(10).seconds.run(myfunc,args= @["foo","uggar"])