Nim's type cast syntax is sometimes looking annoying. Here is a syntactic sugar 
I used recently.
    
    
    proc `[]`*[T](x: T, U: typedesc): U = cast[U](x)
    
    var i = 1
    echo cast[float](i)
    echo i[float]
    
    echo cast[int](i.addr)
    echo i.addr[int]
    
    
    Run

Looking like seq[int], clear and easy. 

Reply via email to