proc foo(x, y): ...
to be syntactic sugar for
proc foo[A, B](x: A, y: B): ...
On the other hand, I often see "compressed type declarations" (for lack of a better name), such as
type Foo = object
x, y: int
It seems to me, then, that the following has two reasonable meanings:
proc foo(x, y: int)
Either x is generic and y is an int, or both x and y are int. I think the latter is the correct interpretation, but I find it slightly confusing.
Is there a way to disambiguate - for instance a way to have auto generics in a declaration where one of the arguments actually has a fixed type?
Try using semicolons. See this example:
proc foo(x, y) =
echo "x: ", x, " y: ", y
proc bar(x: int, y) =
echo "x: ", x, " y: ", y
proc fooBar(x; y: int) =
echo "x: ", x, " y: ", y
proc test() =
foo("a", 3)
bar(2, "b")
fooBar("f", 4)
fooBar(0, 4)
when isMainModule: test()