You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(I'm not really sure if it's a bug or just an extension of the current type parameters mechanism that wasn't proposed or implemented yet, so please feel free to merge into other issues or close as duplicate.)
I've been playing around with the current type params implementation, and found that this code:
$ gotip run --gcflags '-G=3' ./go/typar/main.go
# command-line-arguments
go/typar/main.go:69:7: interface is (or embeds) comparable
gotip version is go version devel go1.17-3e48c0381f Wed Jul 21 20:29:18 2021 +0000 linux/amd64.
The intention here is to have an interface, nullableMakeable, that is the interface of types that are nullable, have a length, and that can be instantiated with make. I haven't found anything prohibiting this in the draft design/proposal, although it's a rather big document, so I might have missed something.
The text was updated successfully, but these errors were encountered:
By the way, the proposal currently says that comparable, like all constraints, can be embedded:
Since comparable, like all constraints, is an interface type, it can be embedded in another interface type used as a constraint:
// ComparableHasher is a type constraint that matches all
// comparable types with a Hash method.
type ComparableHasher interface {
comparable
Hash() uintptr
}
So at the very least the error message “interface is (or embeds) comparable” is misleading, as it implies that embedding comparable is prohibited.
@ainar-g, I am not sure if you will get useful signal from building things with "gotip run --gcflags '-G=3' " -- gotip tracks the master branch, whereas active development of generics has moved (a while back) to the "dev.typeparams" branch.
Would also like to reiterate that we don't use the issue tracker for questions in Go, I think you would be better off bringing up your question about embedding "comparable" on the golang-dev mailing list.
Closing out this issue, please re-open if you disagree with the above. Thanks.
(I'm not really sure if it's a bug or just an extension of the current type parameters mechanism that wasn't proposed or implemented yet, so please feel free to merge into other issues or close as duplicate.)
I've been playing around with the current type params implementation, and found that this code:
Doesn't compile:
gotip version
isgo version devel go1.17-3e48c0381f Wed Jul 21 20:29:18 2021 +0000 linux/amd64
.The intention here is to have an interface,
nullableMakeable
, that is the interface of types that are nullable, have a length, and that can be instantiated withmake
. I haven't found anything prohibiting this in the draft design/proposal, although it's a rather big document, so I might have missed something.The text was updated successfully, but these errors were encountered: