Hello,

I'm sure this functionality exists, however having a real hard time finding the 
answer.

How to you query the type of an object?

>From what I've been trying, type() only seems to work for primitive types.

I've also tried to find the answer in "Nim in Action".

In my search I also found the module typetraits, however name() doesn't seem to 
work either.

For example:

import strutils, typetraits, unicode 
    
    
    type
      Token = object of RootObj
      Integer = ref object of Token
      String = ref object of Token
    
    let d = Integer()
    let c = String()
    
    echo name(d)
    
    
    Run

Gives: 
    
    
    main.nim(17, 10) Error: type mismatch: got (Integer)
    but expected one of:
    proc name(t: typedesc): string
    exit status 1
    
    
    Run

Reply via email to