Not sure if that's what you want but maybe it helps:
    
    
    import std/macrocache
    
    const nextTypeId = CacheCounter("nextTypeId")
    
    type TypeId = int
    
    func typeId*(T:typedesc): TypeId =
        const id = nextTypeId.value
        static:
            inc nextTypeId
        id
    
    echo typeId(int)
    echo typeId(string)
    echo typeId(float)
    echo typeId(int)
    
    
    Run

Reply via email to