[swift-evolution] [Pich] allow embed type declaration in protocol & allow throw in property getter/setter
Adrian Zubarev
adrian.zubarev at devandartist.com
Fri Oct 7 13:10:05 CDT 2016
+1 for nested everything (yes even extensions for local reasons where sometime you don’t want to write extension Outer.Middle.Inner) and maybe another shorthand form for nesting types.
We already have this extension Outer.Inner { … }. So why not allow struct/enum/class/protocol Outer.NewName { … } to reduce some clustering in some places.
Last one is additive + not everything I mentioned is trivial to implement (I’d guess).
--
Adrian Zubarev
Sent with Airmail
Am 7. Oktober 2016 um 20:00:20, Benjamin Spratling via swift-evolution (swift-evolution at swift.org) schrieb:
+1 nested types in protocols
And nested protocols in types.
-1 on throwing properties.
> On Oct 7, 2016, at 10:30 AM, Cao Jiannan via swift-evolution <swift-evolution at swift.org> wrote:
>
> 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)
> }
> }
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
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/20161007/f9809b4a/attachment.html>
More information about the swift-evolution
mailing list