I tried next two variants and they are working as expected: 
    
    
    #proc test[T](x: T) = # this signature doesn't work. Why?!
    proc test[T:not(array|seq)](x: T) =
      echo x
    
    proc test_impl[T](x: openarray[T]) =
      for i in x:
        echo i
    
    proc test[T:array|seq](x: T) =
      test_impl x
    
    test(1)
    test([1, 2, 3])
    test([1, 2, 3, 4])
    test(@[1, 2, 3])
    

or: 
    
    
    proc test[T](x: T) =
      echo x
    
    proc test_impl[T](x: openarray[T]) =
      for i in x:
        echo i
    
    proc test[T](x: seq[T]) =
      test_impl x
    
    proc test[R,T](x: array[R,T]) =
      test_impl x
    
    test(1)
    test([1, 2, 3])
    test([1, 2, 3, 4])
    test(@[1, 2, 3])
    

Reply via email to