swift-book
swift-book copied to clipboard
Add more existentials documentation
This PR contains a few changes to add more documentation around existentials. Note that the "Protocols" chapter comes before the "OpaqueTypes" chapter.
- Expand the section
Protocols as Typeswith other examples of using protocols as types- Personally I think these are a more common than "as a generic constraint", and hence deserve some elaboration
- Explicitly call the result of protocol composition a Protocol Composition Type.
- Prior to this PR, the result does not have an explicit name in the Language Guide.
Protocol Composition Typeis the named used by the Language Reference. - The Generics chapter implicitly uses the name
Protocol Compositionfor this. In my mind, this is a short form.
- Prior to this PR, the result does not have an explicit name in the Language Guide.
- Explicitly say that existentials can use protocol composition types.
- Delete the "opaque type" section in the protocols chapter. The same material seems to be present in the OpaqueTypes chapter.