-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spec: type identity section not fully updated for 1.9 #22202
Comments
I don't see any issues here:
Regarding ordering: It's difficult to come up with the "best order" in a language spec that is naturally recursive. Thanks for the suggestion, but for now I prefer leaving it as is, because a) there's hyperlinks that make it easy to jump around, and b) people got used to the current order. Closing. |
The changes I made were more concerning the lines I took out:
What exactly is the purpose of these two lines? |
See #9226 for a discussion. |
Change https://golang.org/cl/87417 mentions this issue: |
Every few months we get a new error report claiming that there is a typo in the spec related to this specific example. Clearly, the fact that two types with the same identifier are identical seems exceedingly obvious to readers; thus the example seems not worth the trouble. Removing it. For #9226. For #22202. For #22495. For #23096. For #23409. There may be more. Change-Id: I003ba79dc460ffb028a4ecb5f29efd60f2551912 Reviewed-on: https://go-review.googlesource.com/87417 Reviewed-by: Brad Fitzpatrick <[email protected]> Reviewed-by: Rob Pike <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Matthew Dempsky <[email protected]>
The
Type identity
(link) section of the doc has the following:these types are identical:
B0
andB1
are different because they are new types created by distinct type definitions;func(int, float64) *B0
andfunc(x int, y float64) *[]string
are different becauseB0
is different from[]string
.Suggested fix
these types are identical:
B0
andB1
are different because they are new types created by distinct type definitions. Similarly,func(int, float64) *B0
andfunc(x int, y float64) *A1
are different becauseB0
andA1
are created by distinct type definitions (A1
is an alias of[]string
whileB0
is a new, distinct type with the same underlying type as[]string
.Rationale
This section of the docs was not completely updated to reflect the addition of alias declarations. I also recommend moving the "Properties of types and values" section containing "Type identity" down under the "Declarations" (specifically "Type declarations"), so the concept of alias declarations is introduced before they are used.
The text was updated successfully, but these errors were encountered: