Skip to content

Commit 4daaa48

Browse files
authored
Rename Type -> type, per #2360. (#2507)
Also make minor updates to the skeletal design in docs/design/name_lookup.md following #2113, as there are no longer any prelude names that are made available to unqualified name lookup by default. Add `type` to the keyword list in docs/design/lexical_conventions/words.md, following #2360.
1 parent a1ad39f commit 4daaa48

File tree

193 files changed

+573
-571
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+573
-571
lines changed

common/fuzzing/proto_to_carbon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ static auto ExpressionToCarbon(const Fuzzing::Expression& expression,
371371
break;
372372

373373
case Fuzzing::Expression::kTypeTypeLiteral:
374-
out << "Type";
374+
out << "type";
375375
break;
376376

377377
case Fuzzing::Expression::kUnimplementedExpression:

docs/design/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2583,10 +2583,10 @@ given any type `T` that implements the `Ordered` interface. Subsequent calls to
25832583
`Ordered`.
25842584

25852585
The parameter could alternatively be declared to be a _template_ generic
2586-
parameter by prefixing with the `template` keyword, as in `template T:! Type`.
2586+
parameter by prefixing with the `template` keyword, as in `template T:! type`.
25872587

25882588
```carbon
2589-
fn Convert[template T:! Type](source: T, template U:! Type) -> U {
2589+
fn Convert[template T:! type](source: T, template U:! type) -> U {
25902590
var converted: U = source;
25912591
return converted;
25922592
}
@@ -2621,7 +2621,7 @@ declaration, and the condition can only use constant values known at
26212621
type-checking time, including `template` parameters.
26222622

26232623
```carbon
2624-
class Array(template T:! Type, template N:! i64)
2624+
class Array(template T:! type, template N:! i64)
26252625
if N >= 0 and N < MaxArraySize / sizeof(T);
26262626
```
26272627

@@ -2630,7 +2630,7 @@ provided by the caller, _in addition_ to any constraints. This means member name
26302630
lookup and type checking for anything
26312631
[dependent](generics/terminology.md#dependent-names) on the template parameter
26322632
can't be completed until the template is instantiated with a specific concrete
2633-
type. When the constraint is just `Type`, this gives semantics similar to C++
2633+
type. When the constraint is just `type`, this gives semantics similar to C++
26342634
templates. Constraints can then be added incrementally, with the compiler
26352635
verifying that the semantics stay the same. Once all constraints have been
26362636
added, removing the word `template` to switch to a checked parameter is safe.
@@ -2825,7 +2825,7 @@ to a class must be generic, and so defined with `:!`, either with or without the
28252825
type `T`:
28262826

28272827
```carbon
2828-
class Stack(T:! Type) {
2828+
class Stack(T:! type) {
28292829
fn Push[addr self: Self*](value: T);
28302830
fn Pop[addr self: Self*]() -> T;
28312831
@@ -2847,7 +2847,7 @@ The values of type parameters are part of a type's value, and so may be deduced
28472847
in a function call, as in this example:
28482848

28492849
```carbon
2850-
fn PeekTopOfStack[T:! Type](s: Stack(T)*) -> T {
2850+
fn PeekTopOfStack[T:! type](s: Stack(T)*) -> T {
28512851
var top: T = s->Pop();
28522852
s->Push(top);
28532853
return top;
@@ -2868,7 +2868,7 @@ PeekTopOfStack(&int_stack);
28682868
[Choice types](#choice-types) may be parameterized similarly to classes:
28692869

28702870
```carbon
2871-
choice Result(T:! Type, Error:! Type) {
2871+
choice Result(T:! type, Error:! type) {
28722872
Success(value: T),
28732873
Failure(error: Error)
28742874
}
@@ -2880,7 +2880,7 @@ Interfaces are always parameterized by a `Self` type, but in some cases they
28802880
will have additional parameters.
28812881

28822882
```carbon
2883-
interface AddWith(U:! Type);
2883+
interface AddWith(U:! type);
28842884
```
28852885

28862886
Interfaces without parameters may only be implemented once for a given type, but
@@ -2904,11 +2904,11 @@ parameter list_`]` after the `impl` keyword introducer, as in:
29042904

29052905
```carbon
29062906
external impl forall [T:! Printable] Vector(T) as Printable;
2907-
external impl forall [Key:! Hashable, Value:! Type]
2907+
external impl forall [Key:! Hashable, Value:! type]
29082908
HashMap(Key, Value) as Has(Key);
29092909
external impl forall [T:! Ordered] T as PartiallyOrdered;
29102910
external impl forall [T:! ImplicitAs(i32)] BigInt as AddWith(T);
2911-
external impl forall [U:! Type, T:! As(U)]
2911+
external impl forall [U:! type, T:! As(U)]
29122912
Optional(T) as As(Optional(U));
29132913
```
29142914

@@ -3123,7 +3123,7 @@ There are some situations where the common type for two types is needed:
31233123
will be set to the common type of the corresponding arguments, as in:
31243124

31253125
```carbon
3126-
fn F[T:! Type](x: T, y: T);
3126+
fn F[T:! type](x: T, y: T);
31273127
31283128
// Calls `F` with `T` set to the
31293129
// common type of `G()` and `H()`:

docs/design/classes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1084,7 +1084,7 @@ Other type constants can be defined using a `let` declaration:
10841084
```
10851085
class MyClass {
10861086
let Pi:! f32 = 3.141592653589793;
1087-
let IndexType:! Type = i32;
1087+
let IndexType:! type = i32;
10881088
}
10891089
```
10901090

docs/design/expressions/arithmetic.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,15 @@ following family of interfaces:
193193
```
194194
// Unary `-`.
195195
interface Negate {
196-
let Result:! Type = Self;
196+
let Result:! type = Self;
197197
fn Op[self: Self]() -> Result;
198198
}
199199
```
200200

201201
```
202202
// Binary `+`.
203-
interface AddWith(U:! Type) {
204-
let Result:! Type = Self;
203+
interface AddWith(U:! type) {
204+
let Result:! type = Self;
205205
fn Op[self: Self](other: U) -> Result;
206206
}
207207
constraint Add {
@@ -211,8 +211,8 @@ constraint Add {
211211

212212
```
213213
// Binary `-`.
214-
interface SubWith(U:! Type) {
215-
let Result:! Type = Self;
214+
interface SubWith(U:! type) {
215+
let Result:! type = Self;
216216
fn Op[self: Self](other: U) -> Result;
217217
}
218218
constraint Sub {
@@ -222,8 +222,8 @@ constraint Sub {
222222

223223
```
224224
// Binary `*`.
225-
interface MulWith(U:! Type) {
226-
let Result:! Type = Self;
225+
interface MulWith(U:! type) {
226+
let Result:! type = Self;
227227
fn Op[self: Self](other: U) -> Result;
228228
}
229229
constraint Mul {
@@ -233,8 +233,8 @@ constraint Mul {
233233

234234
```
235235
// Binary `/`.
236-
interface DivWith(U:! Type) {
237-
let Result:! Type = Self;
236+
interface DivWith(U:! type) {
237+
let Result:! type = Self;
238238
fn Op[self: Self](other: U) -> Result;
239239
}
240240
constraint Div {
@@ -244,8 +244,8 @@ constraint Div {
244244

245245
```
246246
// Binary `%`.
247-
interface ModWith(U:! Type) {
248-
let Result:! Type = Self;
247+
interface ModWith(U:! type) {
248+
let Result:! type = Self;
249249
fn Op[self: Self](other: U) -> Result;
250250
}
251251
constraint Mod {

docs/design/expressions/as_expressions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ var m: auto = b as T as U;
7878
```
7979

8080
**Note:** `b as (bool as Hashable)` is valid but not useful, because
81-
[the second operand of `as` is implicitly converted to type `Type`](#extensibility).
81+
[the second operand of `as` is implicitly converted to type `type`](#extensibility).
8282
This expression therefore has the same interpretation as `b as bool`.
8383

8484
**TODO:** We should consider making `as` expressions left-associative now that
@@ -164,15 +164,15 @@ Explicit casts can be defined for user-defined types such as
164164
[classes](../classes.md) by implementing the `As` interface:
165165

166166
```
167-
interface As(Dest:! Type) {
167+
interface As(Dest:! type) {
168168
fn Convert[self: Self]() -> Dest;
169169
}
170170
```
171171

172172
The expression `x as U` is rewritten to `x.(As(U).Convert)()`.
173173

174174
**Note:** This rewrite causes the expression `U` to be implicitly converted to
175-
type `Type`. The program is invalid if this conversion is not possible.
175+
type `type`. The program is invalid if this conversion is not possible.
176176

177177
## Alternatives considered
178178

docs/design/expressions/bitwise.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,15 +197,15 @@ implementing the following family of interfaces:
197197
```
198198
// Unary `^`.
199199
interface BitComplement {
200-
let Result:! Type = Self;
200+
let Result:! type = Self;
201201
fn Op[self: Self]() -> Result;
202202
}
203203
```
204204

205205
```
206206
// Binary `&`.
207-
interface BitAndWith(U:! Type) {
208-
let Result:! Type = Self;
207+
interface BitAndWith(U:! type) {
208+
let Result:! type = Self;
209209
fn Op[self: Self](other: U) -> Result;
210210
}
211211
constraint BitAnd {
@@ -215,8 +215,8 @@ constraint BitAnd {
215215

216216
```
217217
// Binary `|`.
218-
interface BitOrWith(U:! Type) {
219-
let Result:! Type = Self;
218+
interface BitOrWith(U:! type) {
219+
let Result:! type = Self;
220220
fn Op[self: Self](other: U) -> Result;
221221
}
222222
constraint BitOr {
@@ -226,8 +226,8 @@ constraint BitOr {
226226

227227
```
228228
// Binary `^`.
229-
interface BitXorWith(U:! Type) {
230-
let Result:! Type = Self;
229+
interface BitXorWith(U:! type) {
230+
let Result:! type = Self;
231231
fn Op[self: Self](other: U) -> Result;
232232
}
233233
constraint BitXor {
@@ -237,8 +237,8 @@ constraint BitXor {
237237

238238
```
239239
// Binary `<<`.
240-
interface LeftShiftWith(U:! Type) {
241-
let Result:! Type = Self;
240+
interface LeftShiftWith(U:! type) {
241+
let Result:! type = Self;
242242
fn Op[self: Self](other: U) -> Result;
243243
}
244244
constraint LeftShift {
@@ -248,8 +248,8 @@ constraint LeftShift {
248248

249249
```
250250
// Binary `>>`.
251-
interface RightShiftWith(U:! Type) {
252-
let Result:! Type = Self;
251+
interface RightShiftWith(U:! type) {
252+
let Result:! type = Self;
253253
fn Op[self: Self](other: U) -> Result;
254254
}
255255
constraint RightShift {

docs/design/expressions/comparison_operators.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ The `EqWith` interface is used to define the semantics of the `==` and `!=`
253253
operators for a given pair of types:
254254

255255
```
256-
interface EqWith(U:! Type) {
256+
interface EqWith(U:! type) {
257257
fn Equal[self: Self](u: U) -> bool;
258258
default fn NotEqual[self: Self](u: U) -> bool {
259259
return not (self == u);
@@ -353,7 +353,7 @@ choice Ordering {
353353
Greater,
354354
Incomparable
355355
}
356-
interface OrderedWith(U:! Type) {
356+
interface OrderedWith(U:! type) {
357357
fn Compare[self: Self](u: U) -> Ordering;
358358
default fn Less[self: Self](u: U) -> bool {
359359
return self.Compare(u) == Ordering.Less;
@@ -432,7 +432,7 @@ implemented. The behaviors of such overrides should follow those of the above
432432
default implementations, and the members of an `OrderedWith` implementation
433433
should have no observable side-effects.
434434

435-
`OrderedWith` implementations should be _transitive_. That is, given `V:! Type`,
435+
`OrderedWith` implementations should be _transitive_. That is, given `V:! type`,
436436
`U:! OrderedWith(V)`, `T:! OrderedWith(U) & OrderedWith(V)`, `a: T`, `b: U`,
437437
`c: V`, then:
438438

docs/design/expressions/if.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ The interface `CommonTypeWith` is used to customize the behavior of
8787
`CommonType`:
8888

8989
```
90-
interface CommonTypeWith(U:! Type) {
91-
let Result:! Type
90+
interface CommonTypeWith(U:! type) {
91+
let Result:! type
9292
where Self is ImplicitAs(.Self) and
9393
U is ImplicitAs(.Self);
9494
}
@@ -120,15 +120,15 @@ The interface `SymmetricCommonTypeWith` is an implementation detail of the
120120
`CommonType` constraint. It is defined and implemented as follows:
121121

122122
```
123-
interface SymmetricCommonTypeWith(U:! Type) {
124-
let Result:! Type
123+
interface SymmetricCommonTypeWith(U:! type) {
124+
let Result:! type
125125
where Self is ImplicitAs(.Self) and
126126
U is ImplicitAs(.Self);
127127
}
128128
match_first {
129-
impl forall [T:! Type, U:! CommonTypeWith(T)]
129+
impl forall [T:! type, U:! CommonTypeWith(T)]
130130
T as SymmetricCommonTypeWith(U) where .Result = U.Result {}
131-
impl forall [U:! Type, T:! CommonTypeWith(U)]
131+
impl forall [U:! type, T:! CommonTypeWith(U)]
132132
T as SymmetricCommonTypeWith(U) where .Result = T.Result {}
133133
}
134134
```
@@ -152,10 +152,10 @@ the `CommonType` constraint is not met. For example, given:
152152

153153
```
154154
// Implementation #1
155-
impl forall [T:! Type] MyX as CommonTypeWith(T) where .Result = MyX {}
155+
impl forall [T:! type] MyX as CommonTypeWith(T) where .Result = MyX {}
156156
157157
// Implementation #2
158-
impl forall [T:! Type] MyY as CommonTypeWith(T) where .Result = MyY {}
158+
impl forall [T:! type] MyY as CommonTypeWith(T) where .Result = MyY {}
159159
```
160160

161161
`MyX as CommonTypeWith(MyY)` will select #1, and `MyY as CommonTypeWith(MyX)`
@@ -167,15 +167,15 @@ because result types differ.
167167
If `T` is the same type as `U`, the result is that type:
168168

169169
```
170-
final impl forall [T:! Type] T as CommonTypeWith(T) where .Result = T {}
170+
final impl forall [T:! type] T as CommonTypeWith(T) where .Result = T {}
171171
```
172172

173173
_Note:_ This rule is intended to be considered more specialized than the other
174174
rules in this document.
175175

176176
Because this `impl` is declared `final`, `T.(CommonType(T)).Result` is always
177177
assumed to be `T`, even in contexts where `T` involves a generic parameter and
178-
so the result would normally be an unknown type whose type-of-type is `Type`.
178+
so the result would normally be an unknown type whose type-of-type is `type`.
179179

180180
```
181181
fn F[T:! Hashable](c: bool, x: T, y: T) -> HashCode {
@@ -189,7 +189,7 @@ fn F[T:! Hashable](c: bool, x: T, y: T) -> HashCode {
189189
If `T` implicitly converts to `U`, the common type is `U`:
190190

191191
```
192-
impl forall [T:! Type, U:! ImplicitAs(T)]
192+
impl forall [T:! type, U:! ImplicitAs(T)]
193193
T as CommonTypeWith(U) where .Result = T {}
194194
```
195195

docs/design/expressions/implicit_conversions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ extends
207207
[the `As` interface used to implement `as` expressions](as_expressions.md#extensibility):
208208

209209
```
210-
interface ImplicitAs(Dest:! Type) {
210+
interface ImplicitAs(Dest:! type) {
211211
extends As(Dest);
212212
// Inherited from As(Dest):
213213
// fn Convert[self: Self]() -> Dest;

0 commit comments

Comments
 (0)