@cdome The distinct helped, but was not enough. It seems Nim has problems 
deciding how to convert an "uint" to a string, so I also needed to specify 
"proc $(uint)":
    
    
    const MAX_THREADS* = 64
    const MAX_TOPICS* = 1048576
    
    const MAX_PROCESSES* = int(4294967296'i64 div int64(MAX_THREADS * 
MAX_TOPICS))
    
    type
      ThreadID* = distinct range[0'u8..uint8(MAX_THREADS-1)]
        ## Thread ID, within process.
      ProcessID* = distinct range[0'u16..uint16(MAX_PROCESSES-1)]
        ## Process ID of thread.
      TopicID* = distinct range[0'u32..uint32(MAX_TOPICS-1)]
        ## TopicID, within thread.
    
    proc `$` *(i: uint): string {.inline.} =
      $uint64(i)
    
    proc `==` *(a, b: ThreadID): bool {.borrow.}
    proc `$` *(id: ThreadID): string {.borrow.}
    proc `==` *(a, b: ProcessID): bool {.borrow.}
    proc `$` *(id: ProcessID): string {.borrow.}
    proc `==` *(a, b: TopicID): bool {.borrow.}
    proc `$` *(id: TopicID): string {.borrow.}
    
    type
      QueueID* = distinct uint32
        ## The complete queue ID, containing the process ID, thread ID and 
topic ID.
    
    proc tid*(queue: QueueID): ThreadID {.inline, noSideEffect.} =
      ## Dummy simplified impl!
      ThreadID(uint8(queue))
    
    proc pid*(queue: QueueID): ProcessID {.inline, noSideEffect.} =
      ## Dummy simplified impl!
      ProcessID(uint16(queue))
    
    proc cid*(queue: QueueID): TopicID {.inline, noSideEffect.} =
      ## Dummy simplified impl!
      TopicID(uint32(queue))
    
    proc `$` *(queue: QueueID): string =
      ## String representation of a QueueID.
      $pid(queue) & "." & $tid(queue) & "." & $cid(queue)
    

Reply via email to