mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 09:21:03 +01:00
The "generics" feature of Carbon is a large design effort that needs to be broken up into manageable steps. The first thing we need is a high-level goals document. The goals here reflect the desirable properties that we have discovered as part of considering several alternative generics designs:
- Use cases:
- Generic programming
- Upgrade path from C++ abstract interfaces
- Dependency injection
- Generics instead of open overloading and ADL
- Performance
- Better compiler experience
- Encapsulation
- Predictability
- Dispatch control
- Upgrade path from templates
- Coherence
- No novel name lookup
- Learn from others
- Interfaces are nominal
- Interop and evolution
- Bridge for C++ customization points
Goals are summarized in [this presentation](https://docs.google.com/presentation/d/12yGyu5Pvdag7CJp-_yLVkmbhyvuRIilBTNlkO0LKaHo/edit?usp=sharing&resourcekey=0-JB9yrUO4-6J8-zzGhnIyNg).
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
Co-authored-by: Matthew Riley <mdriley@gmail.com>
Co-authored-by: austern <austern@google.com>
Co-authored-by: Dmitri Gribenko <gribozavr@gmail.com>
39 lines
1.3 KiB
Markdown
39 lines
1.3 KiB
Markdown
# Generics goals
|
|
|
|
<!--
|
|
Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
Exceptions. See /LICENSE for license information.
|
|
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
-->
|
|
|
|
[Pull request](https://github.com/carbon-language/carbon-lang/pull/24)
|
|
|
|
## Problem
|
|
|
|
The "generics" feature of Carbon is a large design effort that needs to be
|
|
broken up into manageable steps. The first thing we need is a high-level goals
|
|
document:
|
|
|
|
- to make sure we agree on the approach we are taking,
|
|
- to clearly communicate expectations to contributors for future steps,
|
|
- to encourage us to solve problems in the design in a consistent way,
|
|
- to provide a yardstick for measuring different alternatives under
|
|
consideration.
|
|
|
|
## Background
|
|
|
|
The question of what a generics feature would look like in Carbon has been an
|
|
ongoing discussion, with many alternative proposals. Of course there have been a
|
|
number of use cases that we want to address with this feature, but over the
|
|
course of this process we have discovered a number of desirable properties we
|
|
would like to achieve with any solution.
|
|
|
|
## Proposal
|
|
|
|
See the [generics goals document](/docs/design/generics/goals.md).
|
|
|
|
## Rationale
|
|
|
|
The goals here well reflect Carbon's goals as applied to the specifics of the
|
|
generics feature.
|