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

Generics goals #24

Merged
merged 119 commits into from
Apr 24, 2021
Merged

Generics goals #24

merged 119 commits into from
Apr 24, 2021

Conversation

josh11b
Copy link
Contributor

@josh11b josh11b commented May 21, 2020

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.

Copy link
Contributor

@chandlerc chandlerc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking nice. I'd be happy for this to move into the RFC phase as soon as the new process is in place...

docs/project/principles/principle-generics.md Outdated Show resolved Hide resolved
docs/project/principles/principle-generics.md Outdated Show resolved Hide resolved
docs/project/principles/principle-generics.md Outdated Show resolved Hide resolved
docs/project/principles/principle-generics.md Outdated Show resolved Hide resolved
docs/project/principles/principle-generics.md Outdated Show resolved Hide resolved
@josh11b josh11b mentioned this pull request May 30, 2020
@jonmeow jonmeow added proposal A proposal WIP labels Jun 3, 2020
@gribozavr
Copy link
Contributor

There seem to be too many specifics and implementation details in this document for it to be a principle document. It is just my opinion, but I think it would be more appropriate for a principle document to explain the requirements and use cases (generic programming? DSLs? metaprogramming? compatibility with C++?), justify the necessity for both generics and templates in one language, explain the desired place in the language and idiomatic usage patterns for both etc.

@gribozavr
Copy link
Contributor

Another point that would be important to discuss in a high-level doc is whether we want generics to be always monomorphizable. For example, some corner cases of Swift generics can't be monomorphized, even though the vast, vast majority can be. (If you are curious, cases that can't be monomorphized are related to polymorphic recursion https://forums.swift.org/t/ergonomics-generic-types-conforming-in-more-than-one-way/34589/71 or https://stackoverflow.com/questions/40247339/polymorphic-recursion-syntax-and-uses.)

@chandlerc chandlerc changed the base branch from master to trunk July 2, 2020 03:21
@josh11b josh11b requested a review from a team February 24, 2021 22:39
@google-cla google-cla bot added the cla: yes PR meets CLA requirements according to bot. label Feb 24, 2021
Copy link
Contributor

@chandlerc chandlerc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this LGTM now.

However, I'd somewhat prefer to land the script changes as their own PR first, so this change can just introduce the goals for generics. Is that do-able? Would that be super disruptive?

@josh11b
Copy link
Contributor Author

josh11b commented Apr 23, 2021

I think this LGTM now.

However, I'd somewhat prefer to land the script changes as their own PR first, so this change can just introduce the goals for generics. Is that do-able? Would that be super disruptive?

@chandlerc The script changes are because the tests have hard-coded text with the first accepted proposal by number, and this PR has a number less than all the previously accepted ones. So the tests need to be changed at the same time.

Copy link
Contributor

@chandlerc chandlerc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, now that I'm not misunderstanding the script changes, definitely LGTM to me!

@github-actions github-actions bot added proposal accepted Decision made, proposal accepted and removed proposal rfc Proposal with request-for-comment sent out labels Apr 23, 2021
@josh11b josh11b merged commit c42c34d into carbon-language:trunk Apr 24, 2021
@josh11b josh11b deleted the principle-generics branch April 24, 2021 00:19
@josh11b josh11b mentioned this pull request May 6, 2021
@josh11b josh11b mentioned this pull request May 26, 2021
josh11b added a commit that referenced this pull request Jun 29, 2021
This adds an overview of a generics feature that attempts to achieve the goals from #24 . It has been summarized in these presentations:

- [non-type params](https://docs.google.com/presentation/d/1IZaDxP5Y3Wqprkyjzagv48tyxEeIcfz8FZS3Namsvew/edit#slide=id.p)
- [basic usage](https://docs.google.com/presentation/d/1OZiMTVW2Ommop5WTs9RyEwnGxy9yzaAPF7Cj5KUfDsY/edit?resourcekey=0-Nya0Soz3ZNs3hJan8VIrTA#slide=id.p)
- [more advanced usage](https://docs.google.com/presentation/d/1bg6q0Q9Sk4YpRbNA3D3H34xYtaEO8ScAUNUZK2UTi80/edit?resourcekey=0-6-Y6e1mfRUmHg-Zk65Gc5A#slide=id.p)

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
Co-authored-by: Wolff Dobson <wolffg@users.noreply.github.com>
josh11b added a commit that referenced this pull request Aug 11, 2021
chandlerc added a commit that referenced this pull request Jun 28, 2022
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>
chandlerc added a commit that referenced this pull request Jun 28, 2022
This adds an overview of a generics feature that attempts to achieve the goals from #24 . It has been summarized in these presentations:

- [non-type params](https://docs.google.com/presentation/d/1IZaDxP5Y3Wqprkyjzagv48tyxEeIcfz8FZS3Namsvew/edit#slide=id.p)
- [basic usage](https://docs.google.com/presentation/d/1OZiMTVW2Ommop5WTs9RyEwnGxy9yzaAPF7Cj5KUfDsY/edit?resourcekey=0-Nya0Soz3ZNs3hJan8VIrTA#slide=id.p)
- [more advanced usage](https://docs.google.com/presentation/d/1bg6q0Q9Sk4YpRbNA3D3H34xYtaEO8ScAUNUZK2UTi80/edit?resourcekey=0-6-Y6e1mfRUmHg-Zk65Gc5A#slide=id.p)

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
Co-authored-by: Wolff Dobson <wolffg@users.noreply.github.com>
chandlerc pushed a commit that referenced this pull request Jun 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes PR meets CLA requirements according to bot. proposal accepted Decision made, proposal accepted proposal A proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.