News for hackers. Stuff that matters.
Re:Problems with Go's design by pcwalton on Wednesday October 28, 2015 @03:44PM (#10466841)
That's not type covariance. Variance only comes up when you have generics, which Go doesn't, and subtyping, which Go doesn't really have. It's the lack of a coercion/conversion between slice-of-T to slice-of-interface.

The correct language-level solution to #4 is to introduce generics and to allow generic type parameters to have interface bounds. That would solve the problem without having to introduce variance.

Re:Problems with Go's design by Jabbles on Wednesday October 28, 2015 @04:19PM (#10467095)
I don't see how it's not type covariance.

Go's slices are generic to the extent needed, and the subtyping of Go's interfaces fits the requirements for ordering of types well enough.

Re:Problems with Go's design by pcwalton on Wednesday October 28, 2015 @04:21PM (#10467111)
In Go, if T implements interface I, T is not a subtype of the interface type I. T can be converted to the interface type I, but it's not a subtype.
Re:Problems with Go's design by sgeop on Wednesday October 28, 2015 @10:22PM (#10468824)
What's the difference though? Is this true of interfaces in Java for instance, or does it have to do with the specific implementation of go?
Re:Problems with Go's design by mpu on Wednesday October 28, 2015 @03:50PM (#10466881)
Isn't it possible to talk about variance as soon as you have a type constructor (function from types to types)? In this case [].

Edit: I don't know go, but if slices give write access, I think the automatic conversion the author wants would be unsound.

Re:Problems with Go's design by pcwalton on Wednesday October 28, 2015 @04:03PM (#10466962)
Yes, a coercion would be unsound (at least, unless the coercion copied the backing store of the slice, which would be very unintuitive). It shouldn't coerce. I'm describing generic type parameter bounds, which are not the same thing.

(For what it's worth, I'm not sure I would bother solving this problem if I were suddenly put in charge of Go's design, given Go's extreme aversion to type system features. I'm just describing what the solution to this problem typically is.)