[swift-evolution] [Pich] allow embed type declaration in protocol & allow throw in property getter/setter

Cao Jiannan frogcjn at 163.com
Fri Oct 7 10:30:52 CDT 2016


1. allow embed type declaration in protocol
e.g.:

protocol URLProvider {
    fun url() throws -> URL
}

extension URLProvider {
    enum Error: Swift.Error {
         invalidBaseURL
         invalidPath
         invalidQuery
         invalidFragment
    }
}


     func parseURL() throws -> URL {
        throw URLProvider.Error.invalidBaseURL
    }

2. allow throw in property getter/setter

e.g.:

struct myURLProvider: URLProvider {
    var url: throws -> URL {
	try URL(baseURL: baseURL, path: path, query: query, fragment: fragment)
    }
}




More information about the swift-evolution mailing list