[Pitch] allow non-nominal type extension


(frogcjn) #1

e.g.

extension TrackCountProvider & PublishDateProvider {
    var trackCountAndPublishDateText: String {
        var infos: [String] = []
        
        if let trackCount = trackCount {
            infos.append("\(trackCount)")
        }
        
        if let publishDateText = publishDate?.text {
            infos.append(publishDateText)
        }
        
        return infos.joined(separator: seperator)
    }
}


(frogcjn) #2

It is just same as current grammar:

extension TrackCountProvider where Self : PublishDateProvider { ... }

with a more logical format

extension TrackCountProvider & PublishDateProvider { ... }

···

e.g.

extensionTrackCountProvider&PublishDateProvider{
vartrackCountAndPublishDateText:String{
varinfos: [String] = []

iflettrackCount = trackCount{
infos.append("\(trackCount)")

}

ifletpublishDateText = publishDate?.text {
infos.append(publishDateText)
}

returninfos.joined(separator: seperator)
}
}


(Jon Shier) #3

It’s also the same as:

typealias CombinedProtocol = TrackCountProvider & PublishDateProvier

extension CombinedProtocol { }

I, too, find the distinction largely pointless, but I’m not a language designer.

Jon

···

On Oct 20, 2016, at 11:30 PM, Cao Jiannan via swift-evolution <swift-evolution@swift.org> wrote:

It is just same as current grammar:

extension TrackCountProvider where Self : PublishDateProvider { ... }

with a more logical format

extension TrackCountProvider & PublishDateProvider { ... }

> e.g.
>
> extensionTrackCountProvider&PublishDateProvider{
> vartrackCountAndPublishDateText:String{
> varinfos: [String] = []
>
> iflettrackCount = trackCount{
> infos.append("\(trackCount)")
>
> }
>
> ifletpublishDateText = publishDate?.text {
> infos.append(publishDateText)
> }
>
> returninfos.joined(separator: seperator)
> }
> }
>
>
>
>
>
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution