@Udiknedormin many thanks for the thorough explanation and for your correction 
of age from string - silly error on my part.

@stisa thanks for the heads up on dirty templates

I guess the way to generate types using templates is to insert code into a 
template type structure rather than inserting code block templated code into a 
type. I am trying this alternative method similar to the 
[manual](https://nim-lang.org/docs/manual.html#templates-passing-a-code-block-to-a-template)
 and using the `{.inject.}` pragma but it doesn't work:
    
    
    template typeGen(tName, extraCode: untyped): untyped =
      type
        tName {.inject.} = object
          fname: string
          age: int
          extraCode
    
    typeGen(Employee):
      id: int
    
    
    var x = Employee(fname: "Mark", age: 44, id: 962536)
    
    echo x
    

Reply via email to