[swift-evolution] [Pitch] improve import sentence: allow import specific nested types

Robert Widmann devteam.codafi at gmail.com
Thu Sep 29 01:37:22 CDT 2016


2 concerns

1) This introduces an ambiguity in qualified import syntax about whether identifiers after the dot are sub-modules or sub-structures.

2) Rarely do you want to import a substructure without also importing the parent.  Often, APIs designed like there were built with this kind of use-case in mind, so it doesn't make any sense to be able to talk about a part without the whole.  Qualifying access to substructures is not tremendously burdensome and helps enforce modularity and readability in my opinion.  This expansion would harm that.

~Robert Widmann

2016/09/29 1:07、Cao Jiannan via swift-evolution <swift-evolution at swift.org> のメッセージ:

> Now Swift 3 allow us import specific enum/struct from module, but it only allow us import top-level declaration.
> 
> For example:
> 
> in MyFoudnation framework:
> 
> public struct Time {
>     public struct DateOnly {}
> }
> 
> in App target:
> I can only
>  
> import struct MyFoundation.Time
> 
> But I cannot 
> 
> import struct MyFoundation.Time.DateOnly
> 
> So allow developer import nested types
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160929/f3a9aad6/attachment.html>


More information about the swift-evolution mailing list