> On Aug 11, 2016, at 9:39 PM, Douglas Gregor via swift-evolution
> <[email protected]> wrote:
>
> FWIW, I'm planning to write a complete proposal for conditional conformances
> and will start posting drafts once it is far enough along to be useful.
I’m looking forward to that!
I’ll throw a potential use case for this your way, both one of the most obvious
and one of the nastiest I’ve encountered, in case it helps refine the proposal
and/or clarify its limits:
// No more runtime exceptions from things buried in
// dictionaries! Wouldn’t it be nice?
protocol JSONRepresentable { }
// So far so good:
extension String: JSONRepresentable { }
// Hmm, extending protocols is out:
extension Integer: JSONRepresentable { }
extension FloatingPoint: JSONRepresentable { }
// I can imagine a universe where this works:
extension Optional: JSONRepresentable
where Wrapped: JSONRepresentable { }
// ...but this, oh dear:
extension Optional.None: JSONRepresentable { }
// Collection would be better but ... extending protocols again:
extension Array: JSONRepresentable
where Element: JSONRepresentable { }
extension Dictionary: JSONRepresentable
where Key == String, Value: JSONRepresentable { }
I imagine this is all a bridge too far for a proposal at this time — and maybe
a bridge too far for any conditional protocol conformance ever — but it seems
like it needs addressing.
> It won't have support for protocols conforming to other protocols, though.
Curious. Why not? (I’ll happily wait for the proposal if you explain it there.)
Cheers,
Paul
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution