From 549cfefc7233f17e6bf2d79294d11882181e9387 Mon Sep 17 00:00:00 2001
From: Robert Griesemer
Date: Fri, 3 Dec 2021 19:24:54 -0800
Subject: [PATCH] doc/go1.18: expand section on generics
Also, move it up in the document.
Updates #47694
Change-Id: I927c4c845089a5c22e2c5b5f3de1831c04c6d990
Reviewed-on: https://go-review.googlesource.com/c/go/+/369102
Trust: Robert Griesemer
Reviewed-by: Ian Lance Taylor
---
doc/go1.18.html | 78 +++++++++++++++++++++++++++++++++++++------------
1 file changed, 60 insertions(+), 18 deletions(-)
diff --git a/doc/go1.18.html b/doc/go1.18.html
index fb0b054e286..4f485143a99 100644
--- a/doc/go1.18.html
+++ b/doc/go1.18.html
@@ -29,6 +29,66 @@ Do not send CLs removing the interior tags from such phrases.
TODO: complete this section
+Generics
+
+
+ Go 1.18 includes an implementation of generic features as described by the
+ Type
+ Parameters Proposal.
+ This includes major - but fully backward-compatible - changes to the language.
+ The following is a list of the most visible changes. For a more comprehensive overview, see the
+ proposal.
+ For details see the language spec.
+
+
+ -
+ The new token
~
is added to the set of
+ operators and punctuation.
+
+ -
+ The syntax for
+ Function and
+ type declarations
+ now accepts
+ type parameters.
+
+ -
+ The syntax for
+ Interface types
+ now permits the embedding of arbitrary types (not just type names of interfaces)
+ as well as union and
~T
type elements. Such interfaces may only be used
+ as type constraints.
+ An interface now defines a set of types as well as a set of methods.
+
+ -
+ Parameterized functions and types can be instantiated by following them with a list of
+ type arguments in square brackets.
+
+ -
+ The new
+ predeclared identifier
+
any
is an alias for the empty interface. It may be used instead of
+ interface{}
.
+
+ -
+ The new
+ predeclared identifier
+
comparable
is an interface the denotes the set of all types which can be
+ compared using ==
or !=
. It may only be used as (or embedded in)
+ a type constraint.
+
+
+
+
+ The current generics implementation has the following limitations:
+
+ -
+ The Go compiler cannot currently handle type declarations inside generic functions
+ or methods. We hope to provide support for this feature in Go 1.19.
+
+
+
+
Bug fixes
@@ -56,24 +116,6 @@ Do not send CLs removing the interior tags from such phrases.
programs is likely very small.
-Generics
-
-
- Go 1.18 includes an implementation of generics as described
- by the
- generics proposal.
-
-
-
- The current generics implementation has the following limitations:
-
- -
- The Go compiler cannot currently handle type declarations inside generic functions
- or methods. We hope to provide support for this feature in Go 1.19.
-
-
-
-
Fuzzing