aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2021-11-28 17:39:45 -0800
committerIan Lance Taylor <iant@golang.org>2021-11-29 20:00:19 +0000
commit135750a71111d228b1b5c552b20eacb227a663be (patch)
tree1c49c39f32528f3c0f21d7e3dff29272e3185adf
parent5b75384820aef1828b1714cc1d876f70ed545089 (diff)
downloadgo-x-proposal-135750a71111d228b1b5c552b20eacb227a663be.tar.xz
design/43651-type-parameters: absolute difference does not work in 1.18
Change-Id: Ic42e1113c96b087badcb3dcbe6ebd0a6a3460a7d Reviewed-on: https://go-review.googlesource.com/c/proposal/+/367414 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
-rw-r--r--design/43651-type-parameters.md5
1 files changed, 4 insertions, 1 deletions
diff --git a/design/43651-type-parameters.md b/design/43651-type-parameters.md
index 454059e..7ee6dfe 100644
--- a/design/43651-type-parameters.md
+++ b/design/43651-type-parameters.md
@@ -3875,6 +3875,9 @@ It is intended to show how the common part of algorithms can be
factored into code that uses methods, where the exact definition of
the methods can vary based on the kind of type being used.
+Note: the code used in this example will not work in Go 1.18.
+We hope to resolve this and make it work in future releases.
+
```
// NumericAbs matches numeric types with an Abs method.
type NumericAbs[T any] interface {
@@ -3887,7 +3890,7 @@ type NumericAbs[T any] interface {
// AbsDifference computes the absolute value of the difference of
// a and b, where the absolute value is determined by the Abs method.
-func AbsDifference[T NumericAbs](a, b T) T {
+func AbsDifference[T NumericAbs[T]](a, b T) T {
d := a - b
return d.Abs()
}