[swift-evolution] [Discussion] Namespaces

Matthew Johnson matthew at anandabits.com
Fri May 20 11:41:20 CDT 2016


> On May 20, 2016, at 11:16 AM, Adrian Zubarev via swift-evolution <swift-evolution at swift.org> wrote:
> 
>>> 
>>> On May 20, 2016, at 10:54 AM, Adrian Zubarev via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> 
>>> Can submodules enforce the developer to use its name ’Submodule.SomeClass’?
>> 
>> Ideally we would have flexible import syntax that allows for control over *how* names are imported into a lexical context (including the ability to import names within a very specific scope if desired).
> 
> Ok fine.
> 
>>> Do I have to re-build submodules when I made any changes to them before building the outside code base?
>> 
>> All submodules are part of the same target as the module that contains them.
>> 
>>> Can they efficiently used for cross decencies between different modules/submodules?
>> 
>> Cross decencies?  I don’t understand.
> 
> Sorry it’s me again: "cross dependencies“
> 
> MainProject (module/package)
> 
>    |__Submodule
>    |           |__SubSubmodule
>    |__AnotherSubmodule
> 
> Can I enforce usage of `AnotherSubmodule.Someclass` inside of `SubSubmodule`???

With a sufficiently flexible import mechanism you could import `AnotherSubmodule` such that `Someclass` is referenced in the way that you see fit in a specific scope.  You could not require all uses to use the full name `AnotherSubmodule.Someclass`.  That is a stylistic choice.  However, namespaces usually allow for similar flexibility so I don’t see this as a distinction between namespaces and submodules.

>>> Empty enums is an abuse of the language! 
>> 
>> But it is a practical and effective one.  Introducing a new construct like namespaces must carry significant advantages over what is already possible.
> 
> Still abuse of the language no matter how you turn it. I don’t say `namespaces` should only do the same enums do (in my case it would be enough), if there is more they could solve sure why not. Thats a discussion is for isn’t it? I’m not an expert so I want to learn from people that might provide good examples and reasons why namespaces are good or not. 

Yes, as I mentioned elsewhere, I agree that we need more.  But I want us to be clear on what problems we are solving and what capabilities we need.  Empty enums are a good point of reference for that discussion as they are what we have today.

> 
> -- 
> Adrian Zubarev
> Sent with Airmail
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> https://lists.swift.org/mailman/listinfo/swift-evolution <https://lists.swift.org/mailman/listinfo/swift-evolution>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160520/3cbff3ee/attachment.html>


More information about the swift-evolution mailing list