[swift-evolution] Submodules (was: A Problem With SE-0025?)

Matthew Johnson matthew at anandabits.com
Wed Jun 22 15:05:59 CDT 2016


> On Jun 22, 2016, at 12:59 PM, Jordan Rose <jordan_rose at apple.com> wrote:
> 
>> 
>> I would really like to see submodules, but I think there would still be valid uses for `fileprivate` even with them.  But of course we would need to know the details of submodules to have a good discussion about that so it’s a topic for the future. :)
>> 
>> I wonder what became of this: https://github.com/apple/swift/blob/master/docs/Modules.rst#id18 <https://github.com/apple/swift/blob/master/docs/Modules.rst#id18>
> As the author of that document, it became clear (or maybe “it became murky”) that everyone wants different things from submodules, both for compiling their own targets and for importing other people’s targets. I’d almost suggest avoiding the word if you want to propose any of myriad features related to them:

Interesting.  The reason I like the idea of submodules is because I think they could accomplish several of these goals with a single feature in a more elegant manner and without introducing nearly as much complexity as would likely be present with independent features.  

> 
> - importing a subset of APIs
> - having APIs not imported by default with the top-level module

Aren’t these kind of duals of each other (subsets of APIs being submodules, possibly with some APIs directly in the root module)?

> - C++ namespacing within a module

This is perhaps the most straightforward goal, but I believe it would be better served by a more robust submodule feature rather than being a limited namespace feature (for example, integrating with the subset import mentioned above).

> - C++ namespacing within another module

Can you elaborate?  Do you mean namespaces that are “open to extension” in any module similar to how we can extend types from imported modules, provide retroactive conformances, etc?  If that is what you mean I am not at all convinced there is value in this.

> - breaking up compilation units (i.e. not compiling the entire module as one unit)

This feels like it could be a build setting independent of submodules.  For example, if you want WMO to span all submodules you wouldn’t necessarily want this, but if WMO isn’t important maybe you do.

> - adding another access level between internal and fileprivate.

This obviously makes sense in the context of a submodule (or namespace) feature, but feels (to me) like it would be awkward as an independent feature.  

> - adding another access level between fileprivate and private.

Are you thinking of a file that contains scopes from different submodules?  I’m trying to think of how this would do something that the new `private` wouldn’t already be able to do.

> - something else?

The big ones IMO are API subsets, namespaces, and encapsulation (access control) which feel like they fit very nicely together as a single elegant submodule feature.

> 
> (still catching up on the main thread, but I think Robert and Matthew are both right: we need to explicitly amend the proposal, and the behavior we want is fairly obvious)
> 
> Jordan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160622/ef626530/attachment.html>


More information about the swift-evolution mailing list