generic multitype inference, some but not others

59 views
Skip to first unread message

simon place

unread,
Aug 10, 2024, 1:25:59 PM8/10/24
to golang-nuts
any support for partial inference? (can't find/hit on syntax)

like...

```
func X[T Integer,U Integer](t T,u U){}
```

when, say, t can be inferred but not u.

looking for something like...

```
var a uint
 X[_,uint8]X(a,5)]()
```

Axel Wagner

unread,
Aug 10, 2024, 3:12:53 PM8/10/24
to simon place, golang-nuts
That is not possible, currently. You can only omit type parameters from the end of the list, to have them inferred. So, in your case, you are going to have to specify all type parameters.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/334a47a1-6eb7-43b0-9bd8-444efdd86d2an%40googlegroups.com.

simon place

unread,
Aug 10, 2024, 3:30:21 PM8/10/24
to golang-nuts
arrrr, i actually never tried leaving off from the end, that's something. thanks
Reply all
Reply to author
Forward
0 new messages