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

Document default types for associated values #41

Open
natecook1000 opened this issue Sep 15, 2018 · 2 comments
Open

Document default types for associated values #41

natecook1000 opened this issue Sep 15, 2018 · 2 comments
Labels
Content issue A problem in with the book's prose, code, or figures

Comments

@natecook1000
Copy link
Member

Previous ID SR-8761
Radar None
Original Reporter @natecook1000
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s
Labels Improvement
Assignee None
Priority Medium

md5: 5483446fdf4d37083296d04e708f33f2

Issue Description:

We don't appear to document the way you can provide a default type in an associate's type declaration. Noted in https://forums.swift.org/t/a-question-about-associatedtype-in-protocols/16168

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@schwa
Copy link

schwa commented Oct 5, 2022

This is used quite a fair bit in the standard library for doing things like providing a default implementation of a Collection's Slice type

associatedtype SubSequence : Collection = Slice<Self> where Self.Element == Self.SubSequence.Element, Self.SubSequence == Self.SubSequence.SubSequence

It seems strange that a really useful and used (at least in std lib) isn't documented at all in the Swift book

@natecook1000
Copy link
Member Author

Now that TSPL is open source, I've opened #40 to track this issue.

@amartini51 amartini51 reopened this Oct 5, 2022
@amartini51 amartini51 transferred this issue from swiftlang/swift Oct 5, 2022
@amartini51 amartini51 changed the title [SR-8761] Document default types for associated values Document default types for associated values Oct 5, 2022
@amartini51 amartini51 added the Content issue A problem in with the book's prose, code, or figures label Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content issue A problem in with the book's prose, code, or figures
Projects
None yet
Development

No branches or pull requests

3 participants