When a proc call a macro with typedesc parameter, we can just user the type 
name, but when we call another macro in the macro and pass the typedesc 
parameter to it, something is strange, look at the code:
    
    
    type
       User = object
          id: int
          name: string
          age: int
    
    macro stepTwo(T: typedesc): untyped =
       echo "In step 2:   "
       echo repr T.getType()
    
    macro m2(T: typedesc): untyped =
       let nT = quote do: `T`              #Sym "User"
       let t1 = T.getType()[1]             #Sym "User"
       let t2 = bindSym"User"              #Sym "User"
       
       echo t1 == nT  # true
       echo t1 == t2  # true
       echo t2 == nT  # true
       
       #result = newCall("stepTwo", t1)    # ERROR!!
       #result = newCall("stepTwo", t2)    # ERROR!!
       result = newCall("stepTwo", nT)     # OK!
    
    m2(User)
    

How can I pass the User as typedesc paramter to the macro stepTwo if there is 
no 'T' parameter? Why the t1, t2 cannot be treated as correct typedesc, they 
all Sym "User" just like nT.

Help needed, thanks. 

Reply via email to