constraints: move to x/exp for Go 1.18 #50792
There are still questions about the the constraints package. To start with, although many people are happy with the name, many are not. On top of that, it is unclear exactly which interfaces are important and should be present and which should be not. More generally, all the considerations that led us to move slices and maps to x/exp apply to constraints as well.
We left constraints behind in the standard library because we believed it was fundamental to using generics, but in practice that hasn't proven to be the case. In particular, most code uses any or comparable. If those are the only common constraints, maybe we don't need the package. Or if constraints.Ordered is the only other commonly used constraint, maybe that should be a predeclared identifier next to any and comparable. The ability to abbreviate simple constraints let us remove constraints.Chan, constraints.Map, and constraints.Slice, which probably would have been commonly used, but they're gone.
Unlike other interfaces like, say, context.Context, there is no compatibility issue with having a constraint interface defined in multiple packages. The problems that happen with duplicate interfaces involve other types built using that type, such as
For all these reasons, it probably makes sense to move constraints to x/exp along with slices and maps for Go 1.18 and then revisit it in the Go 1.19 or maybe Go 1.20 cycle. (Realistically, we may not know much more for Go 1.19 than we do now.)
The text was updated successfully, but these errors were encountered:
Move to exp from the pre-1.18 standard library. For golang/go#45458 For golang/go#50792 Change-Id: I70f054c9d68c20e98e750f6501f3eabd04a70f17 Reviewed-on: https://go-review.googlesource.com/c/exp/+/382535 Trust: Ian Lance Taylor <email@example.com> Run-TryBot: Ian Lance Taylor <firstname.lastname@example.org> Reviewed-by: Robert Griesemer <email@example.com> TryBot-Result: Gopher Robot <firstname.lastname@example.org>
…kage Following decision in golang/go#50792 Change-Id: I71d74b4b386aacef5319663c397479cac6feb32f Reviewed-on: https://go-review.googlesource.com/c/website/+/383694 Reviewed-by: DO NOT USE <email@example.com> Reviewed-by: Eli Bendersky <firstname.lastname@example.org>
This avoids importing the constraints package, which is no longer in the standard library. For golang/go#50792 Change-Id: I0e0f48d414e87418a1fe95e500bb7629127007cc Reviewed-on: https://go-review.googlesource.com/c/website/+/383254 Reviewed-by: Eli Bendersky <email@example.com> Reviewed-by: Eli Bendersky <firstname.lastname@example.org> Trust: DO NOT USE <email@example.com> Run-TryBot: DO NOT USE <firstname.lastname@example.org> TryBot-Result: Gopher Robot <email@example.com>