Skip to content
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

Updates to design docs to reflect accepted proposals #3254

Merged
merged 102 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from 100 commits
Commits
Show all changes
102 commits
Select commit Hold shift + click to select a range
a27a55f
Checkpoint progress.
josh11b Jul 7, 2023
79534cd
Checkpoint progress.
josh11b Jul 10, 2023
36dccde
Checkpoint progress.
josh11b Jul 11, 2023
afc6b8c
Checkpoint progress.
josh11b Jul 11, 2023
51ebdb5
Checkpoint progress.
josh11b Jul 12, 2023
0377c36
finish a pass on terminology
josh11b Jul 12, 2023
d75f2e6
internal/external -> extend
josh11b Jul 13, 2023
52017c9
Fix references to external section
josh11b Jul 13, 2023
2ffeb6c
Move away from internal/external
josh11b Jul 14, 2023
4b408ec
Fix internal/external in details
josh11b Jul 14, 2023
f8de9bb
Missed one since it was capitalized
josh11b Jul 14, 2023
5970a64
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Jul 14, 2023
99243e9
Update generics goals
josh11b Jul 14, 2023
573840a
Checkpoint progress.
josh11b Jul 15, 2023
5aa8316
Checkpoint progress.
josh11b Jul 16, 2023
d3c911a
Checkpoint progress.
josh11b Jul 16, 2023
38c6b19
Terminology update
josh11b Jul 28, 2023
fb26030
Checkpoint progress.
josh11b Jul 28, 2023
c453b2c
Checkpoint progress.
josh11b Jul 31, 2023
07e132f
Checkpoint progress.
josh11b Aug 1, 2023
cb10315
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Aug 1, 2023
cd54e3b
Checkpoint progress.
josh11b Aug 1, 2023
9e11df2
Checkpoint progress.
josh11b Aug 1, 2023
24f5f4c
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Aug 1, 2023
baaf1a6
iterate on overview
josh11b Aug 3, 2023
721dd25
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Aug 3, 2023
895a546
Checkpoint progress.
josh11b Aug 3, 2023
3f445fa
Finished a pass through generics overview
josh11b Aug 3, 2023
81e67b0
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Aug 3, 2023
330f21d
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Aug 14, 2023
c2e00f2
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Aug 15, 2023
9538ba1
Incomplete work on member_access
josh11b Aug 16, 2023
cedabbb
Iterating on member_access.md
josh11b Aug 23, 2023
9b126b1
Checkpoint progress.
josh11b Aug 23, 2023
a392b27
Checkpoint progress.
josh11b Aug 25, 2023
aa2d84e
Checkpoint progress.
josh11b Aug 25, 2023
c8f2d67
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Aug 25, 2023
4618f9a
Checkpoint progress.
josh11b Aug 29, 2023
2a054f4
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Aug 29, 2023
bb870f1
Checkpoint progress.
josh11b Aug 29, 2023
45380aa
Split out witness tables as an appendix
josh11b Aug 29, 2023
40da45e
Finish up witness table appendix
josh11b Aug 30, 2023
35fc943
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Aug 30, 2023
c9a0500
Iterate on README
josh11b Aug 31, 2023
b1b7331
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Aug 31, 2023
98c6a5c
Update member_access
josh11b Aug 31, 2023
026607a
Checkpoint progress.
josh11b Aug 31, 2023
d324719
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Sep 1, 2023
7207b0b
Checkpoint progress.
josh11b Sep 2, 2023
d211bed
Checkpoint progress.
josh11b Sep 5, 2023
ed9ab2b
Checkpoint progress.
josh11b Sep 5, 2023
7d4ba5f
Checkpoint progress.
josh11b Sep 5, 2023
8b3b852
Checkpoint progress.
josh11b Sep 6, 2023
1f8ca85
Checkpoint progress.
josh11b Sep 6, 2023
ec5322c
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Sep 6, 2023
f04f468
Checkpoint progress.
josh11b Sep 6, 2023
28750c2
Checkpoint progress.
josh11b Sep 6, 2023
79f804d
Add appendix links to README
josh11b Sep 6, 2023
015feed
Checkpoint progress.
josh11b Sep 6, 2023
6b12e61
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Sep 6, 2023
d581340
Checkpoint progress.
josh11b Sep 6, 2023
9a7dcda
Checkpoint progress.
josh11b Sep 7, 2023
818952a
Checkpoint progress.
josh11b Sep 7, 2023
343d683
Checkpoint progress.
josh11b Sep 7, 2023
1150a14
Checkpoint progress.
josh11b Sep 8, 2023
927063c
Checkpoint progress.
josh11b Sep 8, 2023
6a0c51c
Checkpoint progress.
josh11b Sep 8, 2023
ef5a2ea
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Sep 8, 2023
1c74755
Checkpoint progress.
josh11b Sep 9, 2023
ef6ea39
Checkpoint progress.
josh11b Sep 10, 2023
60485dc
Big restructuring
josh11b Sep 11, 2023
d261718
Checkpoint progress.
josh11b Sep 12, 2023
9b8a58c
Checkpoint progress.
josh11b Sep 13, 2023
ec807a4
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Sep 13, 2023
a1b91e1
Checkpoint progress.
josh11b Sep 13, 2023
4a7b974
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Sep 14, 2023
9f8bea2
Checkpoint progress.
josh11b Sep 15, 2023
50523e7
Finished where constraints section
josh11b Sep 15, 2023
6fa60d7
Checkpoint progress.
josh11b Sep 16, 2023
83be850
Checkpoint progress.
josh11b Sep 16, 2023
4b6f972
Checkpoint progress.
josh11b Sep 16, 2023
168dd05
Compile-time `let`
josh11b Sep 18, 2023
6f0d8e4
Checkpoint progress.
josh11b Sep 19, 2023
40c1008
Checkpoint progress.
josh11b Sep 19, 2023
9ec4875
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Sep 19, 2023
dae31ac
Checkpoint progress.
josh11b Sep 19, 2023
39cb449
Checkpoint progress.
josh11b Sep 21, 2023
dfd07f7
Checkpoint progress.
josh11b Sep 21, 2023
c69f4cf
Checkpoint progress.
josh11b Sep 21, 2023
59be2cf
Checkpoint progress.
josh11b Sep 21, 2023
6bade88
Checkpoint progress.
josh11b Sep 21, 2023
88e436b
Checkpoint progress.
josh11b Sep 21, 2023
33da103
Checkpoint progress.
josh11b Sep 21, 2023
f6d1e19
Checkpoint progress.
josh11b Sep 22, 2023
301216d
Checkpoint progress.
josh11b Sep 22, 2023
260b813
Checkpoint progress.
josh11b Sep 22, 2023
20bc45f
Checkpoint progress.
josh11b Sep 22, 2023
f97f2ae
Merge remote-tracking branch 'upstream/trunk' into d
josh11b Sep 22, 2023
c111698
Checkpoint progress.
josh11b Sep 22, 2023
115703a
Checkpoint progress.
josh11b Sep 22, 2023
58b9611
Apply suggestions from code review
josh11b Sep 23, 2023
538ef71
Fix formatting
josh11b Sep 23, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions docs/design/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1604,14 +1604,13 @@ fn Foo() -> f32 {
}
```

> **Note:** This is provisional, no design for `match` statements has been
> through the proposal process yet.

> References:
>
> - [Pattern matching](pattern_matching.md)
> - Question-for-leads issue
> [#1283: how should pattern matching and implicit conversion interact?](https://github.com/carbon-language/carbon-lang/issues/1283)
> - Proposal
> [#2188: Pattern matching syntax and semantics](https://github.com/carbon-language/carbon-lang/pull/2188)

## User-defined types

Expand Down Expand Up @@ -3562,9 +3561,6 @@ imported, so a wrapper may be added without requiring changes to importers?

### Templates

> **Note:** This is provisional, no design for this has been through the
> proposal process yet.

Carbon supports both
[checked and template generics](#checked-and-template-parameters). This provides
a migration path for C++ template code:
Expand All @@ -3591,6 +3587,11 @@ toolchain. However, even when using Carbon's generated C++ headers for interop,
we will include the ability where possible to use a Carbon generic from C++ as
if it were a C++ template.

> References:
>
> - Proposal
> [#2200: Template generics](https://github.com/carbon-language/carbon-lang/pull/2200)

### Standard types

> **Note:** This is provisional, no design for this has been through the
Expand Down
27 changes: 14 additions & 13 deletions docs/design/classes.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ implemented in descendants.
While it is typical for this case to be associated with single-level inheritance
hierarchies, there are some cases where there is an interface at the root of a
type hierarchy and polymorphic types as interior branches of the tree. The case
of generic interfaces extending or requiring other interface would also be
modeled by deeper inheritance hierarchies.
of interfaces extending or requiring other interface would also be modeled by
deeper inheritance hierarchies.

An interface as base class needs to either have a virtual destructor or forbid
deallocation.
Expand All @@ -325,7 +325,7 @@ that support dynamic dispatch are called _object-safe_, following

- They don't have a `Self` in the signature of a method in a contravariant
position like a parameter.
- They don't have free associated types or other associated items used in a
- They don't have free associated facets or other associated items used in a
method signature.

The restrictions on object-safe interfaces match the restrictions on base class
Expand Down Expand Up @@ -910,7 +910,7 @@ which must be an
then match pattern '`self:` _type_' against it".

If the method declaration also includes
[deduced generic parameters](/docs/design/generics/overview.md#deduced-parameters),
[deduced compile-time parameters](/docs/design/generics/overview.md#deduced-parameters),
the `self` parameter must be in the same list in square brackets `[`...`]`. The
`self` parameter may appear in any position in that list, as long as it appears
after any names needed to describe its type.
Expand Down Expand Up @@ -1595,7 +1595,7 @@ class MyDerivedClass {

The properties of a type, whether type is abstract, base, or final, and whether
the destructor is virtual or non-virtual, determines which
[type-of-types](/docs/design/generics/terminology.md#facet-type) it satisfies.
[facet types](/docs/design/generics/terminology.md#facet-type) it satisfies.

- Non-abstract classes are `Concrete`. This means you can create local and
member variables of this type. `Concrete` types have destructors that are
Expand Down Expand Up @@ -1623,7 +1623,7 @@ conform to the decision on
| final | any | yes | yes | yes |

The compiler automatically determines which of these
[type-of-types](/docs/design/generics/terminology.md#facet-type) a given type
[facet types](/docs/design/generics/terminology.md#facet-type) a given type
satisfies. It is illegal to directly implement `Concrete`, `Deletable`, or
`Destructible` directly. For more about these constraints, see
josh11b marked this conversation as resolved.
Show resolved Hide resolved
["destructor constraints" in the detailed generics design](/docs/design/generics/details.md#destructor-constraints).
Expand All @@ -1644,8 +1644,9 @@ interface Allocator {
}
```

To pass a pointer to a base class without a virtual destructor to a generic
function expecting a `Deletable` type, use the `UnsafeAllowDelete`
To pass a pointer to a base class without a virtual destructor to a
checked-generic function expecting a `Deletable` type, use the
`UnsafeAllowDelete`
[type adapter](/docs/design/generics/details.md#adapting-types).

```
Expand All @@ -1670,7 +1671,7 @@ and not implemented in the current class.

Types satisfy the
[`TrivialDestructor`](/docs/design/generics/details.md#destructor-constraints)
type-of-type if:
facet type if:

- the class declaration does not define a destructor or the class defines the
destructor with an empty body `{ }`,
Expand Down Expand Up @@ -1949,11 +1950,11 @@ We want four things so that Carbon's object-safe interfaces may interoperate
with C++ abstract base classes without data members, matching the
[interface as base class use case](#interface-as-base-class):

- Ability to convert an object-safe interface (a type-of-type) into an
- Ability to convert an object-safe interface (a facet type) into an
C++-compatible base class (a base type), maybe using
`AsBaseClass(MyInterface)`.
- Ability to convert a C++ base class without data members (a base type) into
an object-safe interface (a type-of-type), maybe using `AsInterface(MyIBC)`.
an object-safe interface (a facet type), maybe using `AsInterface(MyIBC)`.
- Ability to convert a (thin) pointer to an abstract base class to a `DynPtr`
of the corresponding interface.
- Ability to convert `DynPtr(MyInterface)` values to a proxy type that extends
Expand Down Expand Up @@ -2160,7 +2161,7 @@ implementations for [data classes](#data-classes) more generally. These
implementations will typically subject to the criteria that all the data fields
of the type must implement the interface. An example use case would be to say
that a data class is serializable if all of its fields were. For this we will
need a type-of-type for capturing that criteria, maybe something like
need a facet type for capturing that criteria, maybe something like
`DataFieldsImplement(MyInterface)`. The templated implementation will need some
way of iterating through the fields so it can perform operations fieldwise. This
feature should also implement the interfaces for any tuples whose fields satisfy
Expand Down Expand Up @@ -2239,7 +2240,7 @@ the type of `U.x`."
- [Allow functions to act as destructors](/proposals/p1154.md#allow-functions-to-act-as-destructors)
- [Allow private destructors](/proposals/p1154.md#allow-private-destructors)
- [Allow multiple conditional destructors](/proposals/p1154.md#allow-multiple-conditional-destructors)
- [Type-of-type naming](/proposals/p1154.md#type-of-type-naming)
- [Facet type naming](/proposals/p1154.md#type-of-type-naming)
- [Other approaches to extensible classes without vtables](/proposals/p1154.md#other-approaches-to-extensible-classes-without-vtables)

- [#2107: Clarify rules around `Self` and `.Self`](https://github.com/carbon-language/carbon-lang/pull/2107)
Expand Down
12 changes: 6 additions & 6 deletions docs/design/expressions/arithmetic.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ following family of interfaces:
```
// Unary `-`.
interface Negate {
let Result:! type = Self;
default let Result:! type = Self;
fn Op[self: Self]() -> Result;
}
```

```
// Binary `+`.
interface AddWith(U:! type) {
let Result:! type = Self;
default let Result:! type = Self;
fn Op[self: Self](other: U) -> Result;
}
constraint Add {
Expand All @@ -212,7 +212,7 @@ constraint Add {
```
// Binary `-`.
interface SubWith(U:! type) {
let Result:! type = Self;
default let Result:! type = Self;
fn Op[self: Self](other: U) -> Result;
}
constraint Sub {
Expand All @@ -223,7 +223,7 @@ constraint Sub {
```
// Binary `*`.
interface MulWith(U:! type) {
let Result:! type = Self;
default let Result:! type = Self;
fn Op[self: Self](other: U) -> Result;
}
constraint Mul {
Expand All @@ -234,7 +234,7 @@ constraint Mul {
```
// Binary `/`.
interface DivWith(U:! type) {
let Result:! type = Self;
default let Result:! type = Self;
fn Op[self: Self](other: U) -> Result;
}
constraint Div {
Expand All @@ -245,7 +245,7 @@ constraint Div {
```
// Binary `%`.
interface ModWith(U:! type) {
let Result:! type = Self;
default let Result:! type = Self;
fn Op[self: Self](other: U) -> Result;
}
constraint Mod {
Expand Down
12 changes: 6 additions & 6 deletions docs/design/expressions/bitwise.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,15 @@ implementing the following family of interfaces:
```
// Unary `^`.
interface BitComplement {
let Result:! type = Self;
default let Result:! type = Self;
fn Op[self: Self]() -> Result;
}
```

```
// Binary `&`.
interface BitAndWith(U:! type) {
let Result:! type = Self;
default let Result:! type = Self;
fn Op[self: Self](other: U) -> Result;
}
constraint BitAnd {
Expand All @@ -216,7 +216,7 @@ constraint BitAnd {
```
// Binary `|`.
interface BitOrWith(U:! type) {
let Result:! type = Self;
default let Result:! type = Self;
fn Op[self: Self](other: U) -> Result;
}
constraint BitOr {
Expand All @@ -227,7 +227,7 @@ constraint BitOr {
```
// Binary `^`.
interface BitXorWith(U:! type) {
let Result:! type = Self;
default let Result:! type = Self;
fn Op[self: Self](other: U) -> Result;
}
constraint BitXor {
Expand All @@ -238,7 +238,7 @@ constraint BitXor {
```
// Binary `<<`.
interface LeftShiftWith(U:! type) {
let Result:! type = Self;
default let Result:! type = Self;
fn Op[self: Self](other: U) -> Result;
}
constraint LeftShift {
Expand All @@ -249,7 +249,7 @@ constraint LeftShift {
```
// Binary `>>`.
interface RightShiftWith(U:! type) {
let Result:! type = Self;
default let Result:! type = Self;
fn Op[self: Self](other: U) -> Result;
}
constraint RightShift {
Expand Down
6 changes: 3 additions & 3 deletions docs/design/expressions/comparison_operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ User-defined types can extend the behavior of the comparison operators by
implementing interfaces. In this section, various properties are specified that
such implementations "should" satisfy. These properties are not enforced in
general, but the standard library might detect violations of some of them in
some circumstances. These properties may be assumed by generic code, resulting
in unexpected behavior if they are violated.
some circumstances. These properties may be assumed by checked-generic code,
resulting in unexpected behavior if they are violated.

#### Equality

Expand Down Expand Up @@ -460,7 +460,7 @@ than or equivalent to themselves.

**TODO:** The standard library should provide a way to specify that an ordering
is a weak, partial, or total ordering, and a way to request such an ordering in
a generic.
a checked generic.

#### Compatibility of equality and ordering

Expand Down
4 changes: 2 additions & 2 deletions docs/design/expressions/if.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ _Note:_ This rule is intended to be considered more specialized than the other
rules in this document.

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

```
fn F[T:! Hashable](c: bool, x: T, y: T) -> HashCode {
Expand Down
2 changes: 1 addition & 1 deletion docs/design/expressions/indexing.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pointer, and do not automatically chain with customized dereference interfaces.

**Open question:** It's not clear that the lack of chaining is necessary, and it
might be more expressive for the pointer type returned by the `Addr` methods to
be an associated type with a default to allow types to produce custom
be an associated facet with a default to allow types to produce custom
pointer-like types on their indexing boundary and have them still be
automatically dereferenced.

Expand Down
4 changes: 2 additions & 2 deletions docs/design/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ the `a` and `b` parameters of `Add`.
Other designs build upon basic function syntax to add advanced features:

- [Generic functions](generics/overview.md#generic-functions) adds support for
deduced parameters and generic type parameters.
deduced parameters and compile-time parameters.
- [Class member functions](classes.md#member-functions) adds support for
methods and class functions.

## Alternatives considered

- [Function keyword](/proposals/p0438.md#function-keyword)
- [Only allow `auto` return types if parameters are generic](/proposals/p0826.md#only-allow-auto-return-types-if-parameters-are-generic)
- [Only allow `auto` return types if parameters are compile-time](/proposals/p0826.md#only-allow-auto-return-types-if-parameters-are-generic)
- [Provide alternate function syntax for concise return type inference](/proposals/p0826.md#provide-alternate-function-syntax-for-concise-return-type-inference)
- [Allow separate declaration and definition](/proposals/p0826.md#allow-separate-declaration-and-definition)

Expand Down
15 changes: 9 additions & 6 deletions docs/design/generics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ feature of Carbon:

- [Overview](overview.md) - A high-level description of the generics design,
with pointers to other design documents that dive deeper into individual
topics.
topics
- [Goals](goals.md) - The motivation and principles guiding the design
direction.
direction
- [Terminology](terminology.md) - A glossary establishing common terminology
for describing the design.
- [Detailed design](details.md) - In depth description of how generic type
parameters work.
- ~~Rejected alternatives~~ - not implemented yet
for describing the design
- [Detailed design](details.md) - In-depth description
- [Appendix: Witness tables](appendix-witness.md) - Describes an
implementation strategy for checked generics, and Carbon's rationale for
only using it for dynamic dispatch
- [Appendix: Coherence](appendix-coherence.md) - Describes the rationale
for Carbon's choice to have coherent generics, and the alternatives
josh11b marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions docs/design/generics/appendix-witness.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ class Vector {
}
```

The [impl of `Vector` for `Point_Inline`](details.md#inline-impl) would be a
value of this type:
The [`impl` definition of `Vector` for `Point_Inline`](details.md#inline-impl)
would be a value of this type:

```
var VectorForPoint_Inline: Vector = {
Expand Down
Loading
Loading