generics and absence of ability to specify correlated types

126 views
Skip to first unread message

Dan Kortschak

unread,
Jun 17, 2020, 7:25:17 AM6/17/20
to golang-nuts
Since this has come up again in [1], I would like to re-raise the issue
of being able to correlate float and complex types so that a
func(float32) complex64/func(float64) complex128-like function can be
written generically. This issue was raised in [2] in the last round of
generics discussions with the example now in [3] and [4].

This wasn't addressed last time, and it does not appear to be addressed
in the current document, although the Point method section comes sort
of close[5] by doing essentially the same kind of conversion/constraint
but with pointers, also the `ComplexAbs(type T Complex) T` type,
however this does not handle both the cases below and achieves what it
does in a heavier way.

Dan

[1]
https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md
[2]https://groups.google.com/d/msg/golang-dev/nug_hZnGQog/et4aKG6_DAAJ
[3]https://go2goplay.golang.org/p/gdJNbVmLy8u
[4]https://go2goplay.golang.org/p/Ak6q0CfUT7d
[5]
https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#pointer-methods


Dan Kortschak

unread,
Jun 18, 2020, 6:39:47 PM6/18/20
to golan...@googlegroups.com
With the multitude of answers for use of alternative syntaxes for
specifying type parameter lists, is there a chance that this concern
could be addressed?

thanks
Dan

On Wed, 2020-06-17 at 11:24 +0000, 'Dan Kortschak' via golang-nuts
wrote:
> --
> 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/59e4349d3c0811462c153c4b5905d884b37e442e.camel%40kortschak.io
> .


Reply all
Reply to author
Forward
0 new messages