Skip to content

Commit 79836f7

Browse files
committed
47916-parameterized-go-types.md: spell out 'Type' in APIs
As discussed in #47916, it is clearer to spell out 'Type' rather than use 'T'. Updates #47916 Change-Id: Ib67e6aa33c1df346e487d50f6a1b734bcc949f98 Reviewed-on: https://go-review.googlesource.com/c/proposal/+/348377 Reviewed-by: Robert Findley <[email protected]>
1 parent 2bad773 commit 79836f7

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

design/47916-parameterized-go-types.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,29 +61,29 @@ Type parameters are considered identical (as reported by the `Identical` functio
6161
### Type parameter and type argument lists
6262

6363
```go
64-
type TParamList struct { /* ... */ }
64+
type TypeParamList struct { /* ... */ }
6565

66-
func (*TParamList) Len() int
67-
func (*TParamList) At(i int) *TypeParam
66+
func (*TypeParamList) Len() int
67+
func (*TypeParamList) At(i int) *TypeParam
6868

6969
type TypeList struct { /* ... */ }
7070

7171
func (*TypeList) Len() int
7272
func (*TypeList) At(i int) Type
7373
```
7474

75-
A `TParamList` type is added to represent lists of type parameters. Similarly, a `TypeList` type is added to represent lists of type arguments. Both types have a `Len` and `At` methods, with the only difference between them being the type returned by `At`.
75+
A `TypeParamList` type is added to represent lists of type parameters. Similarly, a `TypeList` type is added to represent lists of type arguments. Both types have a `Len` and `At` methods, with the only difference between them being the type returned by `At`.
7676

7777
### Changes to `types.Named`
7878

7979
```go
80-
func (*Named) TParams() *TParamList
81-
func (*Named) SetTParams([]*TypeParam)
80+
func (*Named) TypeParams() *TypeParamList
81+
func (*Named) SetTypeParams([]*TypeParam)
8282
func (*Named) TArgs() *TypeList
8383
func (*Named) Orig() *Named
8484
```
8585

86-
The `TParams` and `SetTParams` methods are added to `*Named` to get and set type parameters. Once a type parameter has been passed to `SetTParams`, it is considered _bound_ and must not be used in any subsequent calls to `Named.SetTParams` or `Signature.SetTParams`; doing so will panic. For non-parameterized types, `TParams` returns nil.
86+
The `TypeParams` and `SetTypeParams` methods are added to `*Named` to get and set type parameters. Once a type parameter has been passed to `SetTypeParams`, it is considered _bound_ and must not be used in any subsequent calls to `Named.SetTypeParams` or `Signature.SetTypeParams`; doing so will panic. For non-parameterized types, `TypeParams` returns nil.
8787

8888
When a `*Named` type is instantiated (see [instantiation](#instantiation) below), the result is another `*Named` type which retains the original type parameters but gains type arguments. These type arguments are substituted in the underlying type of the original type to produce a new underlying type. Similarly, type arguments are substituted for the corresponding receiver type parameter in method declarations to produce a new method type.
8989

@@ -110,16 +110,16 @@ Parameterized named types continue to be considered identical (as reported by th
110110
### Changes to `types.Signature`
111111

112112
```go
113-
func (*Signature) TParams() *TParamList
114-
func (*Signature) SetTParams([]*TypeParam)
113+
func (*Signature) TypeParams() *TypeParamList
114+
func (*Signature) SetTypeParams([]*TypeParam)
115115

116-
func (*Signature) RParams() *TParamList
116+
func (*Signature) RParams() *TypeParamList
117117
func (*Signature) SetRParams([]*TypeParam)
118118
```
119119

120-
The `TParams` and `SetTParams` methods are added to `*Signature` to get and set type parameters. As described in the section on `*Named` types, passing a type parameter more than once to either `Named.SetTParams` or `Signature.SetTParams` will panic.
120+
The `TypeParams` and `SetTypeParams` methods are added to `*Signature` to get and set type parameters. As described in the section on `*Named` types, passing a type parameter more than once to either `Named.SetTypeParams` or `Signature.SetTypeParams` will panic.
121121

122-
The `RParams` and `SetRParams` methods allow getting and setting receiver type parameters. Signatures cannot have both type parameters and receiver type parameters. For a given receiver `t`, once `t.SetTParams` has been called with a non-empty slice, calling `t.SetRParams` with a non-empty slice will panic, and vice-versa.
122+
The `RParams` and `SetRParams` methods allow getting and setting receiver type parameters. Signatures cannot have both type parameters and receiver type parameters. For a given receiver `t`, once `t.SetTypeParams` has been called with a non-empty slice, calling `t.SetRParams` with a non-empty slice will panic, and vice-versa.
123123

124124
For `Signatures` to be identical (as reported by `Identical`), they must be identical ignoring type parameters, have the same number of type parameters, and have pairwise identical type parameter constraints.
125125

0 commit comments

Comments
 (0)