And one step further from @lucian's template, returning procs:
    
    
    type
        SomeObject*[T: SomeNumber] = object
            val : T
    
    #ex3
    proc test3impl[T : SomeNumber]: SomeObject[T] =
        # all actual code here
        echo "type is " & $T
    template test3*(T : typedesc[SomeNumber] = float) : untyped =
        # a dispatcher: just calling the proc
        test3impl[T]()
    
    #doesn't work
    #echo test3(pointer)
    
    #works
    echo test3()
    echo test3(int)
    echo test3(float)
    echo test3(byte)
    
    
    Run

Reply via email to