You could make some specialized types or exploit some of the combined types 
that Nim already defines. For example:
    
    
    proc double[T: SomeFloat](x : T) : T = x
    proc double[T: SomeInteger](x : T) : T = 2 * x
    
    echo double(1.0)
    echo double(1)
    echo double(1'i64)
    
    
    Run

`SomeInteger` is defined in system.nim 
([https://github.com/nim-lang/Nim/blob/devel/lib/system.nim](https://github.com/nim-lang/Nim/blob/devel/lib/system.nim))
 as:
    
    
    SomeSignedInt* = int|int8|int16|int32|int64
        ## Type class matching all signed integer types.
    
    SomeUnsignedInt* = uint|uint8|uint16|uint32|uint64
        ## Type class matching all unsigned integer types.
    
    SomeInteger* = SomeSignedInt|SomeUnsignedInt
        ## Type class matching all integer types.
    
    
    
    Run

Reply via email to