aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2024-04-04 04:51:24 +0000
committerMichael Knyszek <mknyszek@google.com>2024-04-22 18:14:07 +0000
commita088e230d4e7892b15851babe161bbd1766738a1 (patch)
treeb42bda131142e51a16e6327bb505849a4e60d474 /doc
parent654c3368e53c923acff5fd5a1eaf4175bb6834d6 (diff)
downloadgo-a088e230d4e7892b15851babe161bbd1766738a1.tar.gz
go-a088e230d4e7892b15851babe161bbd1766738a1.zip
unique: add unique package and implement Make/Handle
This change adds the unique package for canonicalizing values, as described by the proposal in #62483. Fixes #62483. Change-Id: I1dc3d34ec12351cb4dc3838a8ea29a5368d59e99 Reviewed-on: https://go-review.googlesource.com/c/go/+/574355 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ingo Oeser <nightlyone@googlemail.com> Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/next/6-stdlib/2-unique.md13
-rw-r--r--doc/next/6-stdlib/99-minor/unique/62483.md1
2 files changed, 14 insertions, 0 deletions
diff --git a/doc/next/6-stdlib/2-unique.md b/doc/next/6-stdlib/2-unique.md
new file mode 100644
index 0000000000..b2c3bdfd0d
--- /dev/null
+++ b/doc/next/6-stdlib/2-unique.md
@@ -0,0 +1,13 @@
+### New unique package
+
+The new [unique](/pkg/unique) package provides facilites for
+canonicalizing values (like "interning" or "hash-consing").
+
+Any value of comparable type may be canonicalized with the new
+`Make[T]` function, which produces a reference to a canonical copy of
+the value in the form of a `Handle[T]`.
+Two `Handle[T]` are equal if and only if the values used to produce the
+handles are equal, allowing programs to deduplicate values and reduce
+their memory footprint.
+Comparing two `Handle[T]` values is efficient, reducing down to a simple
+pointer comparison.
diff --git a/doc/next/6-stdlib/99-minor/unique/62483.md b/doc/next/6-stdlib/99-minor/unique/62483.md
new file mode 100644
index 0000000000..d281ab290e
--- /dev/null
+++ b/doc/next/6-stdlib/99-minor/unique/62483.md
@@ -0,0 +1 @@
+<!-- This is a new package; covered in 6-stdlib/2-unique.md. -->