[swift-evolution] [Pitch] Nested types in protocols (and nesting protocols in types)

Jonathan Hull jhull at gbis.com
Mon Oct 24 13:23:17 CDT 2016


> FWIW, in almost all the situations where I’ve wanted to nest types inside protocols and generic types, it’s only as a namespacing convenience. Most often, it’s an enum type that’s used only by a single method, and having it at the top of the module namespace adds clutter.
> Alternatively, what if (1) outer types aren’t capture unless they’re referenced, and (2) nesting is only illegal if there’s a capture?
I was just about to write something similar, but Paul said it better.

Why don’t we allow everything to be nested in everything for namespacing purposes (which is most of why I want it), but forbid references to generic or associated types from the nested type?  Then, as the generics manifesto gets implemented, we can start allowing certain generics to be referenced over time as they start to become possible and make sense (but we wouldn’t worry about that yet for this proposal)

Is there another issue which would keep that simpler version from working?

Thanks,
Jon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161024/ffd47724/attachment.html>


More information about the swift-evolution mailing list