|
8 | 8 |
|
9 | 9 | ### Comments
|
10 | 10 |
|
11 |
| -The usual `// line comments` and `/* stream comments */` are supported. For exmaple: |
| 11 | +The usual `// line comments` and `/* stream comments */` are supported. For example: |
12 | 12 |
|
13 | 13 | ``` cpp title="Example: Comments"
|
14 | 14 | // A line comment: After //, the entire rest of the line is part of the comment
|
@@ -142,7 +142,7 @@ Types can be qualified with `const` and `*`. Types are written left-to-right, so
|
142 | 142 |
|
143 | 143 | ``` cpp title="Example: Type qualifiers"
|
144 | 144 | // A const pointer to a non-const pointer to a const i32 object
|
145 |
| -p: const * * const i32; // |
| 145 | +p: const * * const i32; |
146 | 146 | ```
|
147 | 147 |
|
148 | 148 | ### Literals
|
@@ -272,7 +272,7 @@ There are two kinds of `is`:
|
272 | 272 |
|
273 | 273 | ### `as` — safe casts and conversions
|
274 | 274 |
|
275 |
| -An `x as T` expression allows safe type casts. `x` must be an object or expression, and `T` must be a type. It supports both static and dynamic typing, including customization with support for the standard dynamically tyuped libraries `std::variant`, `std::optional`, and `std::any` provided in the box. For example: |
| 275 | +An `x as T` expression allows safe type casts. `x` must be an object or expression, and `T` must be a type. It supports both static and dynamic typing, including customization with support for the standard dynamically typed libraries `std::variant`, `std::optional`, and `std::any` provided in the box. For example: |
276 | 276 |
|
277 | 277 | ``` cpp title="Example: Using as"
|
278 | 278 | main: () = {
|
@@ -323,7 +323,7 @@ test: (x) = {
|
323 | 323 | // Sample call site
|
324 | 324 | test(42);
|
325 | 325 | // Behaves as if the following function were called:
|
326 |
| - // test: (x) = { std::cout << (:std::string = "the answer") << "\n";; } |
| 326 | + // test: (x) = { std::cout << (:std::string = "the answer") << "\n"; } |
327 | 327 | // (and that's why inspect alternatives are introduced with '=')
|
328 | 328 | ```
|
329 | 329 |
|
@@ -542,7 +542,7 @@ skat_game: @enum<i16> type = {
|
542 | 542 |
|
543 | 543 | Consider `hearts`: It's a member object declaration, but it doesn't have a type (or a default value) which is normally illegal, but here it's okay because the `@enum<i16>` metafunction fills them in: It iterates over all the data members and gives each one the underlying type (here explicitly specified as `i16`, otherwise it would be computed as the smallest signed type that's big enough), and an initializer (by default one higher than the previous enumerator).
|
544 | 544 |
|
545 |
| -Unlike C `enum`, this `@union` is scoped and strongly type (does not implicitly convert to the underlying type. |
| 545 | +Unlike C `enum`, this `@enum` is scoped and strongly typed (does not implicitly convert to the underlying type. |
546 | 546 |
|
547 | 547 | Unlike C++11 `enum class`, it's "just a `type`" which means it can naturally also have member functions and other things that a type can have:
|
548 | 548 |
|
@@ -616,7 +616,7 @@ Unlike C `union`, this `@union` is safe to use because it always ensures only th
|
616 | 616 |
|
617 | 617 | Unlike C++11 `std::variant`, this `@union` is easier to use because its alternatives are anonymous, and safer to use because each union type is a distinct type. [^variant]
|
618 | 618 |
|
619 |
| -Each `@union` type has its own type-safe name, has clear and unambiguous named members, and safely encapsulates a discriminator to rule them all. Sure, it uses unsafe casts in the implementation, but they are fully encapsulated, where they can be tested once and be safe in all uses. That makes @union: |
| 619 | +Each `@union` type has its own type-safe name, has clear and unambiguous named members, and safely encapsulates a discriminator to rule them all. Sure, it uses unsafe casts in the implementation, but they are fully encapsulated, where they can be tested once and be safe in all uses. |
620 | 620 |
|
621 | 621 | Because a `@union type` is still a `type`, it can naturally have other things normal types can have, such as template parameter lists and member functions:
|
622 | 622 |
|
|
0 commit comments