]> Cypherpunks.ru repositories - gostls13.git/commitdiff
spec: clarify rules for type set construction of an interface
authorRobert Griesemer <gri@golang.org>
Tue, 15 Mar 2022 17:15:53 +0000 (10:15 -0700)
committerRobert Griesemer <gri@golang.org>
Tue, 19 Apr 2022 23:42:38 +0000 (23:42 +0000)
Be explicit that we always mean non-interface types when we
talk about sets of types.

Also, clarify that the quantification "all non-interface types"
means all such types in all possible programs, not just the
current program.

Per suggestion from Philip Wadler.

Change-Id: Ibc7b5823164e547bfcee85d4e523e58c7c27ac8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/398655
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
doc/go_spec.html

index b496e9e48f0dd896546eb50a05347dd05a767bf7..b272cb5df6e119feae5b1d92c459f39f39f8fd64 100644 (file)
@@ -1,6 +1,6 @@
 <!--{
        "Title": "The Go Programming Language Specification",
-       "Subtitle": "Version of March 30, 2022",
+       "Subtitle": "Version of April 19, 2022",
        "Path": "/ref/spec"
 }-->
 
@@ -1278,7 +1278,8 @@ then the <code>File</code> interface is implemented by both <code>S1</code> and
 <p>
 Every type that is a member of the type set of an interface implements that interface.
 Any given type may implement several distinct interfaces.
-For instance, all types implement the <i>empty interface</i> which stands for the set of all types:
+For instance, all types implement the <i>empty interface</i> which stands for the set
+of all (non-interface) types:
 </p>
 
 <pre>
@@ -1380,7 +1381,7 @@ definition of an interface's type set as follows:
                of its interface elements.
        </li>
 
-       <li>The type set of a method specification is the set of types
+       <li>The type set of a method specification is the set of all non-interface types
                whose method sets include that method.
        </li>
 
@@ -1389,7 +1390,7 @@ definition of an interface's type set as follows:
        </li>
 
        <li>The type set of a term of the form <code>~T</code>
-               is the set of types whose underlying type is <code>T</code>.
+               is the set of all types whose underlying type is <code>T</code>.
        </li>
 
        <li>The type set of a <i>union</i> of terms
@@ -1398,6 +1399,15 @@ definition of an interface's type set as follows:
        </li>
 </ul>
 
+<p>
+The quantification "the set of all non-interface types" refers not just to all (non-interface)
+types declared in the program at hand, but all possible types in all possible programs, and
+hence is infinite.
+Similarly, given the set of all non-interface types that implement a particular method, the
+intersection of the method sets of those types will contain exactly that method, even if all
+types in the program at hand always pair that method with another method.
+</p>
+
 <p>
 By construction, an interface's type set never contains an interface type.
 </p>