Thankyou for your reply @mratsim I tried the following: type Data*[T] = object id: string contents: T subscribers: seq[proc(d: T)] proc addSubscriber*[T](d: T, cb: proc(d:T)) = d.subscribers.add(cb) proc callSubscribers[T](d: T) = for cb in d.subscribers: cb(d.contents) var dd = Data[string]() dd.contents = "a content" dd.id = "1" dd.subscribers = newseq[proc(d: string)]() dd.addSubscriber(proc(d: string) = echo $d) dd.callSubscribers() Run
> but I get this error: testproc.nim(19, 3) Error: type mismatch: got <Data[system.string], proc (d: string {.gcsafe, locks: 0.}> but expected one of: proc addSubscriber[T](d: T; cb: proc (d: T)) first type mismatch at position: 2 required type: proc (d: T){.closure.} but expression 'proc (d: string) = echo [$d]' is of type: proc (d: string){.gcsafe, locks: 0.} expression: addSubscriber(dd, proc (d: string) = echo [$d]) Run it seems I'm missing something