about keyword constraint?

97 views
Skip to first unread message

xie cui

unread,
Mar 20, 2022, 1:28:39 AM3/20/22
to golang-nuts
in the period of typeparam development, we have try to add a keyword constraint, why we remove it finally, i am trying to understand why to add it and why to remove int finally.

Axel Wagner

unread,
Mar 20, 2022, 8:10:04 AM3/20/22
to xie cui, golang-nuts
I don't think `constraint` was ever removed. We had `contract` in the design at some point, and some people suggested to add `constraint` to replace it, but it never got done, so it could never have been removed.

As to the reason why `contract` was removed and why `constraint` was not added: When we used two different words for interface-types and contracts to constrain type-parameters, people where complaining that the two are really the same thing - a way to express a subset of types. So, in response to those complaints, `contracts` where removed and instead interfaces where expanded to make up the difference.

Then people complained that we used the same name for two different things.

Point is, interfaces and constraints are apparently sufficiently similar, that many people want to use the same name. And sufficiently different, that many people want to use different names. They can't both have their way.

On Sun, Mar 20, 2022 at 6:28 AM xie cui <cuiw...@gmail.com> wrote:
in the period of typeparam development, we have try to add a keyword constraint, why we remove it finally, i am trying to understand why to add it and why to remove int finally.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/ef365a2e-2ffc-49b7-b7d6-4f660011f611n%40googlegroups.com.

peterGo

unread,
Mar 20, 2022, 9:37:49 AM3/20/22
to golang-nuts
For background information,

Featherweight Go
The Go language famously lacks generics. Our paper introduces a core formal model of Go, Featherweight Go (FG), and explores a design of generics for FG featuring structural typing (Featherweight Generic Go). The semantics of generics are defined via monomorphisation into FG.
Featherweight Go Paper DOI: https://doi.org/10.1145/3428217 Presented at OOPSLA, part of SPLASH 2020 By Robert Griesemer, Raymond Hu, Wen Kokke, Julien Lange, Ian Lance Taylor, Bernardo Toninho, Philip Wadler, Nobuko Yoshida

Peter
Reply all
Reply to author
Forward
0 new messages