That works for your example.
It does not work if I want to treat int's and uints differently: (nb:
SomeSignedInt and SomeUnsignedInt are non-overlapping)
proc double[T: SomeUnsignedInt](x : T) : T = x
proc double[T: SomeSignedInt](x : T) : T = 2 * x
echo double(1) # Error: ambiguous call
Run
It does not work if I want to treat int's and other numbers differently: (nb:
SomeSignedInt is a strict subset of SomeNumber)
proc double[T: SomeNumber](x : T) : T = x
proc double[T: SomeSignedInt](x : T) : T = 2 * x
echo double(1) # Error: ambiguous call
Run
It does not work if I want treat small int's differently:
proc double[T: int8|int16](x : T) : T = x
proc double[T: SomeSignedInt](x : T) : T = 2 * x
echo double(1) # Error: ambiguous call
Run
even if I try :
proc double[T: int8|int16](x : T) : T = x
proc double[T: int|int32|int64](x : T) : T = 2 * x
echo double(1) # Error: ambiguous call
Run