Skip to content

Commit be79866

Browse files
committed
Change remaining uses of Bool to bool, following carbon-language#750.
The most significant change here is that explorer now uses the chosen spelling rather than the old `Bool` spelling. Also update a few documentation examples and some skeletal design docs to use the chosen spelling.
1 parent 9a7914e commit be79866

39 files changed

+81
-77
lines changed

common/fuzzing/proto_to_carbon.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ static auto ExpressionToCarbon(const Fuzzing::Expression& expression,
321321
}
322322

323323
case Fuzzing::Expression::kBoolTypeLiteral:
324-
out << "Bool";
324+
out << "bool";
325325
break;
326326

327327
case Fuzzing::Expression::kBoolLiteral: {

docs/design/classes.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1755,8 +1755,8 @@ declaration with all of the optional parameters in an option struct:
17551755
```
17561756
fn SortIntVector(
17571757
v: Vector(i32)*,
1758-
options: {.stable: Bool = false,
1759-
.descending: Bool = false} = {}) {
1758+
options: {.stable: bool = false,
1759+
.descending: bool = false} = {}) {
17601760
// Code using `options.stable` and `options.descending`.
17611761
}
17621762
@@ -1780,7 +1780,7 @@ We might instead support destructuring struct patterns with defaults:
17801780
```
17811781
fn SortIntVector(
17821782
v: Vector(i32)*,
1783-
{stable: Bool = false, descending: Bool = false}) {
1783+
{stable: bool = false, descending: bool = false}) {
17841784
// Code using `stable` and `descending`.
17851785
}
17861786
```

docs/design/generics/goals.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ There are a few obstacles to supporting dynamic dispatch efficiently, which may
381381
limit the extent it is used automatically by implementations. For example, the
382382
following features would benefit substantially from guaranteed monomorphization:
383383

384-
- Field packing in class layout. For example, packing a `Bool` into the lower
384+
- Field packing in class layout. For example, packing a `bool` into the lower
385385
bits of a pointer, or packing bit-fields with generic widths.
386386
- Allocating local variables in stack storage. Without monomorphization, we
387387
would need to perform dynamic memory allocation -- whether on the stack or

docs/design/generics/overview.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Example:
159159
```
160160
interface Comparable {
161161
// `Less` is an associated method.
162-
fn Less[me: Self](rhs: Self) -> Bool;
162+
fn Less[me: Self](rhs: Self) -> bool;
163163
}
164164
```
165165

@@ -218,7 +218,7 @@ class Song {
218218
// the library defining `Song` or `Comparable`.
219219
external impl Song as Comparable {
220220
// Could use either `Self` or `Song` here.
221-
fn Less[me: Self](rhs: Self) -> Bool { ... }
221+
fn Less[me: Self](rhs: Self) -> bool { ... }
222222
}
223223
```
224224

@@ -350,7 +350,7 @@ Interfaces can require other interfaces be implemented:
350350

351351
```
352352
interface Equatable {
353-
fn IsEqual[me: Self](rhs: Self) -> Bool;
353+
fn IsEqual[me: Self](rhs: Self) -> bool;
354354
}
355355
356356
// `Iterable` requires that `Equatable` is implemented.
@@ -386,7 +386,7 @@ methods in the implementation of the derived interface.
386386
class Key {
387387
// ...
388388
impl as Hashable {
389-
fn IsEqual[me: Key](rhs: Key) -> Bool { ... }
389+
fn IsEqual[me: Key](rhs: Key) -> bool { ... }
390390
fn Hash[me: Key]() -> u64 { ... }
391391
}
392392
// No need to separately implement `Equatable`.
@@ -535,7 +535,7 @@ interface Stack {
535535
let ElementType:! Movable;
536536
fn Push[addr me: Self*](value: ElementType);
537537
fn Pop[addr me: Self*]() -> ElementType;
538-
fn IsEmpty[addr me: Self*]() -> Bool;
538+
fn IsEmpty[addr me: Self*]() -> bool;
539539
}
540540
```
541541

@@ -561,7 +561,7 @@ those types to be different. An element in a hash map might have type
561561

562562
```
563563
interface Equatable(T:! Type) {
564-
fn IsEqual[me: Self](compare_to: T) -> Bool;
564+
fn IsEqual[me: Self](compare_to: T) -> bool;
565565
}
566566
```
567567

docs/design/generics/terminology.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ overloads:
192192

193193
```
194194
fn F[template T:! Type](x: T*) -> T;
195-
fn F(x: Int) -> Bool;
195+
fn F(x: Int) -> bool;
196196
```
197197

198198
A generic function `G` can call `F` with a type like `T*` that can not possibly

docs/design/name_lookup.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ the package scope for unqualified name lookup.
7676

7777
The Carbon standard library is in the `Carbon` package. A very small subset of
7878
this standard library is provided implicitly in every file's scope. This is
79-
called the "prelude" package.
79+
called the "prelude".
8080

81-
Names in the prelude package will be available without scoping names. For
82-
example, `Bool` will be the commonly used name in code, even though the
83-
underlying type may be `Carbon::Bool`. Also, no `import` will be necessary to
84-
use `Bool`.
81+
Names in the prelude will be available without a package qualifier. For
82+
example, the name `Type` can be directly used in code without a `Carbon.`
83+
qualifier, even though it belongs to the `Carbon` package, and no import is
84+
necessary to use the name `Type`.
8585

8686
## Open questions
8787

docs/design/primitive_types.md

+17-13
Original file line numberDiff line numberDiff line change
@@ -37,33 +37,37 @@ modifying other types. They also have semantics that are defined from first
3737
principles rather than in terms of other operations. These will be made
3838
available through the [prelude package](README.md#name-lookup-for-common-types).
3939

40-
- `Bool` - a boolean type with two possible values: `True` and `False`.
41-
- `Int` and `UInt` - signed and unsigned 64-bit integer types.
40+
- `bool` - a boolean type with two possible values: `true` and `false`.
41+
- Signed and unsigned 64-bit integer types:
4242
- Standard sizes are available, both signed and unsigned, including `i8`,
43-
`i16`, `i32`, `i64`, `i128`, and `i256`.
44-
- Overflow in either direction is an error.
45-
- `Float64` - a floating point type with semantics based on IEEE-754.
46-
- Standard sizes are available, including `f16`, `f32`, and `f128`.
43+
`i16`, `i32`, `i64`, and `i128`, and `u8`, `u16`, `u32`, `u64`, and
44+
`u128`.
45+
- Signed overflow in either direction is an error.
46+
- Floating points type with semantics based on IEEE-754.
47+
- Standard sizes are available, including `f16`, `f32`, and `f64`.
4748
- [`BFloat16`](primitive_types.md#bfloat16) is also provided.
4849
- `String` - a byte sequence treated as containing UTF-8 encoded text.
4950
- `StringView` - a read-only reference to a byte sequence treated as
5051
containing UTF-8 encoded text.
5152

53+
The names `bool`, `true`, and `false` are keywords, and identifiers of the form
54+
`i[0-9]*`, `u[0-9]*`, and `f[0-9*]` are _type literals_, resulting in the
55+
corresponding type.
56+
5257
### Integers
5358

5459
Integer types can be either signed or unsigned, much like in C++. Signed
5560
integers are represented using 2's complement and notionally modeled as
56-
unbounded natural numbers. Overflow in either direction is an error. That
57-
includes unsigned integers, differing from C++. The default size for both is
58-
64-bits: `Int` and `UInt`. Specific sizes are also available, for example:
59-
`Int8`, `Int16`, `Int32`, `Int128`, `UInt256`. Arbitrary powers of two above `8`
60-
are supported for both (although perhaps we'll want to avoid _huge_ values for
61-
implementation simplicity).
61+
unbounded natural numbers. Signed overflow in either direction is an error.
62+
Specific sizes are available, for example: `i8`, `u16`, `i32`, and `u128`.
63+
64+
There is an upper bound on the size of an integer, most likely initially set to
65+
128 bits due to LLVM limitations.
6266

6367
### Floats
6468

6569
Floating point types are based on the binary floating point formats provided by
66-
IEEE-754. `Float16`, `Float32`, `Float64` and `Float128` correspond exactly to
70+
IEEE-754. `f16`, `f32`, `f64` and, if available, `f128` correspond exactly to
6771
those sized IEEE-754 formats, and have the semantics defined by IEEE-754.
6872

6973
### BFloat16

docs/project/principles/error_handling.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ way that enables the program to continue running.
3232

3333
A Carbon function that needs to report recoverable failures should return a sum
3434
type whose alternatives represent the success case and failure cases, such as
35-
`Optional(T)`, `Result(T, Error)`, or `Bool`. The function's successful return
35+
`Optional(T)`, `Result(T, Error)`, or `bool`. The function's successful return
3636
value, and any metadata about the failure, should be embedded in the
3737
alternatives of the sum type, rather than reported by way of output parameters
3838
or other side channels. Carbon's design will prioritize making this form of

docs/project/principles/library_apis_only.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ lookup as well.
6161

6262
According to the resolutions of
6363
[#543](https://github.com/carbon-language/carbon-lang/issues/543) and
64-
[#750](https://github.com/carbon-language/carbon-lang/issues/543), Carbon will
64+
[#750](https://github.com/carbon-language/carbon-lang/issues/750), Carbon will
6565
have a substantial number of type keywords, such as `i32`, `f64`, and `bool`.
6666
However, these keywords will all be aliases for ordinary type names, such as
6767
`Carbon.Int(32)`, `Carbon.Float(64)`, and `Carbon.Bool`. Furthermore, all

explorer/ast/expression.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ void Expression::PrintID(llvm::raw_ostream& out) const {
288288
out << (cast<BoolLiteral>(*this).value() ? "true" : "false");
289289
break;
290290
case ExpressionKind::BoolTypeLiteral:
291-
out << "Bool";
291+
out << "bool";
292292
break;
293293
case ExpressionKind::IntTypeLiteral:
294294
out << "i32";

explorer/data/prelude.carbon

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl forall [U1:! Type, U2:! Type, U3:! Type,
5858
// ----------------------
5959

6060
interface EqWith(U:! Type) {
61-
fn Equal[me: Self](other: U) -> Bool;
61+
fn Equal[me: Self](other: U) -> bool;
6262
// TODO: NotEqual with default impl
6363
}
6464
// TODO: constraint Eq { ... }
@@ -67,21 +67,21 @@ interface EqWith(U:! Type) {
6767
// TODO: Simplify this once we have variadics
6868
impl forall [T2:! Type, U2:! Type, T1:! EqWith(T2), U1:! EqWith(U2)]
6969
(T1, U1) as EqWith((T2, U2)) {
70-
fn Equal[me: Self](other: (T2, U2)) -> Bool {
70+
fn Equal[me: Self](other: (T2, U2)) -> bool {
7171
let (l1: T1, l2: U1) = me;
7272
let (r1: T2, r2: U2) = other;
7373
return l1 == r1 and l2 == r2;
7474
}
7575
}
7676

7777
impl i32 as EqWith(Self) {
78-
fn Equal[me: Self](other: Self) -> Bool {
78+
fn Equal[me: Self](other: Self) -> bool {
7979
return __intrinsic_int_eq(me, other);
8080
}
8181
}
8282

8383
impl String as EqWith(Self) {
84-
fn Equal[me: Self](other: Self) -> Bool {
84+
fn Equal[me: Self](other: Self) -> bool {
8585
return __intrinsic_str_eq(me, other);
8686
}
8787
}

explorer/interpreter/interpreter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ class Interpreter {
123123
// Instantiate a type by replacing all type variables that occur inside the
124124
// type by the current values of those variables.
125125
//
126-
// For example, suppose T=i32 and U=Bool. Then
126+
// For example, suppose T=i32 and U=bool. Then
127127
// __Fn (Point(T)) -> Point(U)
128128
// becomes
129-
// __Fn (Point(i32)) -> Point(Bool)
129+
// __Fn (Point(i32)) -> Point(bool)
130130
auto InstantiateType(Nonnull<const Value*> type, SourceLocation source_loc)
131131
-> ErrorOr<Nonnull<const Value*>>;
132132

explorer/interpreter/value.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ void Value::Print(llvm::raw_ostream& out) const {
340340
out << "lval<" << cast<LValue>(*this).address() << ">";
341341
break;
342342
case Value::Kind::BoolType:
343-
out << "Bool";
343+
out << "bool";
344344
break;
345345
case Value::Kind::IntType:
346346
out << "i32";

explorer/syntax/lexer.lpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ARROW "->"
4040
AS "as"
4141
AUTO "auto"
4242
AWAIT "__await"
43-
BOOL "Bool"
43+
BOOL "bool"
4444
BREAK "break"
4545
CARET "^"
4646
CASE "case"

explorer/testdata/basic_syntax/not_compare_precedence.carbon

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
package ExplorerTest api;
1212

13-
fn CompareBools(a: Bool, b: Bool) -> Bool {
13+
fn CompareBools(a: bool, b: bool) -> bool {
1414
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/basic_syntax/not_compare_precedence.carbon:[[@LINE+1]]: syntax error, unexpected EQUAL_EQUAL, expecting SEMICOLON
1515
return not a == b;
1616
}

explorer/testdata/comparison/custom_equality.carbon

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class MyType {
1616
var value: i32;
1717

1818
impl as EqWith(Self) {
19-
fn Equal[me: Self](other: Self) -> Bool {
19+
fn Equal[me: Self](other: Self) -> bool {
2020
return me.value == other.value;
2121
}
2222
}

explorer/testdata/comparison/fail_empty_struct.carbon

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package ExplorerTest api;
1010
// TODO: This should work
1111
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/comparison/fail_empty_struct.carbon:[[@LINE+1]]: type error in call: '{}' is not implicitly convertible to 'Type'
1212
external impl {} as EqWith({}) {
13-
fn Equal[me: Self](other: Self) -> Bool {
13+
fn Equal[me: Self](other: Self) -> bool {
1414
return true;
1515
}
1616
}

explorer/testdata/function/auto_return/fail_direct_recurse.carbon

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ package ExplorerTest api;
1212

1313
// This is required to fail even though the Recurse() call's return value isn't
1414
// used.
15-
fn Recurse(x: i32, do_recurse: Bool) -> auto {
15+
fn Recurse(x: i32, do_recurse: bool) -> auto {
1616
if (do_recurse) {
1717
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/function/auto_return/fail_direct_recurse.carbon:[[@LINE+1]]: Function calls itself, but has a deduced return type
1818
Recurse(x, false);

explorer/testdata/generic_class/fail_argument_deduction.carbon

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ fn FirstOfTwoPoints[T:! Type](a: Point(T), b: Point(T)) -> Point(T) {
2121

2222
fn Main() -> i32 {
2323
var p: Point(i32) = {.x = 0, .y = 1};
24-
var q: Point(Bool) = {.x = true, .y = false};
24+
var q: Point(bool) = {.x = true, .y = false};
2525
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_class/fail_argument_deduction.carbon:[[@LINE+3]]: deduced multiple different values for T:! Type:
2626
// CHECK: i32
27-
// CHECK: Bool
27+
// CHECK: bool
2828
return FirstOfTwoPoints(p, q).x;
2929
}

explorer/testdata/generic_class/fail_point_equal.carbon

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Point(T:! Type) {
1717

1818
fn Main() -> i32 {
1919
var p: Point(i32) = {.x = 0, .y = 0};
20-
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_class/fail_point_equal.carbon:[[@LINE+1]]: type error in name binding: 'class Point(T = i32)' is not implicitly convertible to 'class Point(T = Bool)'
21-
var q: Point(Bool) = p;
20+
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_class/fail_point_equal.carbon:[[@LINE+1]]: type error in name binding: 'class Point(T = i32)' is not implicitly convertible to 'class Point(T = bool)'
21+
var q: Point(bool) = p;
2222
return 0;
2323
}

explorer/testdata/generic_function/apply.carbon

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn apply[T:! Type, U:! Type](f: __Fn (T) -> U, x: T) -> U {
1515
return f(x);
1616
}
1717

18-
fn positive(x: Bool) -> i32 {
18+
fn positive(x: bool) -> i32 {
1919
if (x) {
2020
return 2;
2121
} else {

explorer/testdata/generic_function/fail_type_deduction_mismatch.carbon

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ fn fst[T:! Type](x: T, y: T) -> T {
1717
fn Main() -> i32 {
1818
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/generic_function/fail_type_deduction_mismatch.carbon:[[@LINE+3]]: deduced multiple different values for T:! Type:
1919
// CHECK: i32
20-
// CHECK: Bool
20+
// CHECK: bool
2121
return fst(0, true);
2222
}

explorer/testdata/global_variable/fail_init_type_mismatch.carbon

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ package ExplorerTest api;
1212

1313
// Test type checking of global variable. Error expected.
1414

15-
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/global_variable/fail_init_type_mismatch.carbon:[[@LINE+1]]: type error in initializer of variable: 'Bool' is not implicitly convertible to 'i32'
15+
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/global_variable/fail_init_type_mismatch.carbon:[[@LINE+1]]: type error in initializer of variable: 'bool' is not implicitly convertible to 'i32'
1616
var flag: i32 = true;
1717

1818
fn Main() -> i32 {

explorer/testdata/if_else/convert_condition.carbon

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ package ExplorerTest api;
1414
class LazyEq {
1515
var v1: i32;
1616
var v2: i32;
17-
impl as ImplicitAs(Bool) {
18-
fn Convert[me: Self]() -> Bool {
17+
impl as ImplicitAs(bool) {
18+
fn Convert[me: Self]() -> bool {
1919
return me.v1 == me.v2;
2020
}
2121
}

explorer/testdata/if_expression/convert_condition.carbon

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ package ExplorerTest api;
1414
class LazyEq {
1515
var v1: i32;
1616
var v2: i32;
17-
impl as ImplicitAs(Bool) {
18-
fn Convert[me: Self]() -> Bool {
17+
impl as ImplicitAs(bool) {
18+
fn Convert[me: Self]() -> bool {
1919
return me.v1 == me.v2;
2020
}
2121
}

explorer/testdata/if_expression/if_then_else.carbon

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
package ExplorerTest api;
1313

1414
fn Main() -> i32 {
15-
var cond: if true then Bool else i32 = true;
15+
var cond: if true then bool else i32 = true;
1616
if (if cond then true else false) {}
1717
while (if cond then false else true) {}
1818
return if if cond then true or false else false and true

explorer/testdata/impl/fail_ambiguous_impl_generic.carbon

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ external impl forall [T:! Type] A(T) as B(i32) {}
1717
external impl forall [T:! Type] A(i32) as B(T) {}
1818

1919
fn F[T:! B(i32)](x: T) {}
20-
fn G[T:! B(Bool)](x: T) {}
20+
fn G[T:! B(bool)](x: T) {}
2121

2222
fn Main() -> i32 {
23-
let a: A(Bool) = {};
23+
let a: A(bool) = {};
2424
let b: A(i32) = {};
2525
F(a);
2626
G(b);

explorer/testdata/impl/fail_param_interface_in_impl.carbon

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn Main() -> i32 {
2121
let n: i32 = 0;
2222
CheckSimilar(true, false);
2323
CheckSimilar(true, n);
24-
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/impl/fail_param_interface_in_impl.carbon:[[@LINE+1]]: could not find implementation of interface Similar(T = i32) for Bool
24+
// CHECK: COMPILATION ERROR: {{.*}}/explorer/testdata/impl/fail_param_interface_in_impl.carbon:[[@LINE+1]]: could not find implementation of interface Similar(T = i32) for bool
2525
CheckSimilar(n, false);
2626
return 0;
2727
}

0 commit comments

Comments
 (0)