It works, but I'm not sure if Nim supposed to be used that way?

I declared a generic proc `run` that can handle any type that has `id` field 
and `process` proc defined. So `J` generic type acts like an interface, is it 
ok to use it that way without explicitly specifying those requirements for the 
`J` type?
    
    
    # Generic function that expect that there should be
    # declared `id` field and `process` function for J type
    proc run*[J](job: J): void =
      let id: string = job.id
      let v: string = job.process()
      echo "id=", id, " v", "=", v
    
    type SomeJob = object
      id: string
    
    proc process(job: SomeJob): string = "some value"
    
    SomeJob(id: "1").run()
    
    
    Run

Reply via email to