[Pitch] improve import sentence: allow import specific nested types

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

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@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@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution