fuzion icon indicating copy to clipboard operation
fuzion copied to clipboard

Allow `_` as a placeholder for a type parameter that is to be inferred

Open fridis opened this issue 1 year ago • 0 comments

Look at this code that defines two features x with two and three arguments:

x(T type, v T)    => say "x1 $T $v"
x(T type, v, w T) => say "x2 $T $v $w"

a,b => 42

x i32 a
x a

x i32 a b
x a b     // does and should not work, would call x with two args
x _ a b   // could work, but does not

It is possible to call he first one with type inference for the type parameter x a. But this is not possible for the second one since x a b would be treated like a call to the first with a passed as T and v as v. This may be annoying if types are more complex. We could allow _ as a placeholder for types parameters that are to be inferred, i.e., x _ a b would call x(T,v,w) and infer the type to be passed as T.

fridis avatar Aug 19 '24 07:08 fridis