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

Show example of nested protocols [SE-0404] #235

Merged
merged 10 commits into from
Feb 7, 2024

Conversation

amartini51
Copy link
Member

@amartini51 amartini51 commented Jan 8, 2024

Didn't add an example to the tour, because it doesn't show nested types — we can revise that separately.

Fixes: rdar://117101695

@amartini51 amartini51 marked this pull request as draft January 8, 2024 23:03
@amartini51
Copy link
Member Author

Pulling this back to draft because Dice is used in the running examples, but was removed from this chapter by a17a3dd. We need to rewrite around that change.

This approach doesn't rely (directly or indirectly) on existential
types.  The old example used two protocols at the same scope, in part
because protocol nesting wasn't supported when this was first written.
That's no longer needed -- we can now show a delegate protocol nested
inside the type it supports.
The discussion of how the delegate can access the type that's doing the
delegation is no longer relevant -- DiceGameTracker doesn't access any
game state, and there's no longer a need to define a protocol for the
delegating type to conform to.  So that explanation was removed without
replacement.
@amartini51 amartini51 marked this pull request as ready for review January 31, 2024 21:53
@amartini51
Copy link
Member Author

Added @hborla as a tech reviewer, since GitHub won't let me add @karwa, the proposal author.

Copy link
Contributor

@karwa karwa left a comment

Choose a reason for hiding this comment

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

Nice example!

TSPL.docc/LanguageGuide/Protocols.md Outdated Show resolved Hide resolved
Co-authored-by: Karl <5254025+karwa@users.noreply.github.com>
Copy link
Contributor

@chuckdude chuckdude left a comment

Choose a reason for hiding this comment

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

Approved with suggested edits. There are a couple suggested wording changes in here, but prefer defaulting to overall style of the Guide if there's a conflict.

Please let me know if you'd like to discuss or feel free to incorporate the revisions and merge.

Thank you.

TSPL.docc/LanguageGuide/Protocols.md Outdated Show resolved Hide resolved
TSPL.docc/LanguageGuide/Protocols.md Outdated Show resolved Hide resolved
TSPL.docc/LanguageGuide/Protocols.md Outdated Show resolved Hide resolved
TSPL.docc/LanguageGuide/Protocols.md Outdated Show resolved Hide resolved
TSPL.docc/ReferenceManual/Declarations.md Outdated Show resolved Hide resolved
TSPL.docc/ReferenceManual/Declarations.md Outdated Show resolved Hide resolved
Co-authored-by: Chuck Toporek <chuck_toporek@apple.com>
@amartini51 amartini51 merged commit f6c1070 into swiftlang:main Feb 7, 2024
@amartini51 amartini51 deleted the nested_protocols_117101695 branch February 7, 2024 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants