diff --git a/doc/go_faq.html b/doc/go_faq.html index 33636fca39..f198379fe5 100644 --- a/doc/go_faq.html +++ b/doc/go_faq.html @@ -860,6 +860,36 @@ value to hold the error and a type switch to discriminate cases. The syntax tree example is also doable, although not as elegantly.
++Covariant result types would mean that an interface like + +
+type Copyable interface {
+ Copy() interface{}
+}
+
+
+would be satisfied by the method
+
++func (v Value) Copy() Value ++ +because
Value implements the empty interface.
+In Go method types must match exactly, so Value does not
+implement Copyable.
+Go separates the notion of what a
+type does—its methods—from the type's implementation.
+If two methods return different types, they are not doing the same thing.
+Programmers who want covariant result types are often trying to
+express a type heirarchy through interfaces.
+In Go it's more natural to have a clean separation between interface
+and implementation.
+
+