Cloud the current generic draft constraint a type parameter must be exactly some types

139 views
Skip to first unread message

tapi...@gmail.com

unread,
Sep 18, 2020, 1:06:55 PM9/18/20
to golang-nuts
instead of sharing the same underlying types with some types?

Ian Lance Taylor

unread,
Sep 18, 2020, 1:31:10 PM9/18/20
to tapi...@gmail.com, golang-nuts
On Fri, Sep 18, 2020 at 10:07 AM tapi...@gmail.com <tapi...@gmail.com> wrote:
>
> instead of sharing the same underlying types with some types?

In the current design draft, the answer is yes, but only for
non-predeclared defined types.

https://go.googlesource.com/proposal/+/refs/heads/master/design/go2draft-type-parameters.md#type-lists-in-interface-types

Ian

tapi...@gmail.com

unread,
Sep 18, 2020, 1:59:17 PM9/18/20
to golang-nuts
If sum types are supported can they can be used as general parameter types,
then it is possible to declare overloaded functions/methods demoed in the end of this article.
This might be good for some scenarios.
Reply all
Reply to author
Forward
0 new messages