Files
carbon-lang/proposals
josh11bandRichard Smith f4e9063b97 Generics details 8: interface default and final members (#990)
Allowing interfaces to define default values for its associated entities. This:

-   Helps with evolution by reducing the changes needed to add new members to an interface.
-   Reduces boilerplate when some value is more common than others.
-   Addresses the gap between the minimum necessary for a type to provide the desired functionality of an interface and the breadth of API that user's desire.

As an alternative, final values can be provided instead, which can't be overridden, but are more predictable for users and may avoid dynamic dispatch overhead in some cases.

Example:
```
// Interface parameter has a default of `Self`
interface Add(Right:! Type = Self) {
  // `AddWith` *always* equals `Right`
  final let AddWith:! Type = Right;
  // `Result` has a default of `Self`
  let Result:! Type = Self;
  fn DoAdd[me: Self](right: Right) -> Result;
}

impl String as Add() {
  // Right == AddWith == Result == Self == String
  fn DoAdd[me: Self](right: Self) -> Self;
}
```

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-01-21 14:10:20 -08:00
..
2021-04-23 17:19:23 -07:00
2021-09-23 18:48:37 -07:00
2021-04-21 13:00:03 -07:00
2021-04-21 10:06:44 -07:00
2021-04-13 20:57:17 -07:00
2021-05-10 16:42:01 -07:00
2021-06-29 10:52:45 -07:00
2021-07-08 10:39:36 -07:00
2021-07-09 11:49:32 -07:00
2021-08-03 15:37:18 -07:00
2021-09-23 18:39:54 -07:00
2021-08-27 16:53:21 -07:00
2021-09-21 09:33:32 -07:00
2021-09-08 17:37:35 -07:00
2021-09-21 15:16:16 -07:00
2021-09-23 10:09:57 -07:00
2021-09-21 09:45:35 -07:00
2021-10-29 16:46:19 -07:00
2022-01-10 10:08:14 -08:00

Proposals

Proposal lists

Directory structure

This directory contains accepted proposals for the carbon-lang repository. For information about declined/deferred proposals, please view the proposal's original pull request.

For accepted proposals, where #### is the corresponding proposal's pull request:

  • p####.md will contain the main proposal text.
  • p#### may be present as an optional subdirectory for related files (for example, images).