[swift-evolution] [Proposal Draft] automatic protocol forwarding

Joe Groff jgroff at apple.com
Tue Dec 29 16:21:56 CST 2015

> On Dec 29, 2015, at 12:06 PM, Kevin Ballard via swift-evolution <swift-evolution at swift.org> wrote:
> The downside to this is it needs to be manually declared for each protocol. But I wager that most protocols actually aren't really amenable to forwarding anyway.

At least from a language-mechanics perspective, the only fundamental blocker I can think of that makes a protocol difficult to forward are nontrivial `Self` requirements, since you need a way to map from Foo<Forwarder> to Foo<Forwardee> anywhere the protocol requires Foo<Self>. There's quite a bit of that in the standard library thanks to the collection APIs, to be sure, but I wonder what the breakdown is in the wild for Self-inflicting protocols versus non  outside of the stdlib.

I like the idea of using Forwarder protocols with default implementations, since it's amenable to macro generation and doesn't require new language features, but like Matt noted, it's easy to do the wrong thing from an API exposure standpoint by accidentally publishing your type's FooableForwarder conformance when you only wanted to promise that your type was Fooable.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151229/ec5d85eb/attachment.html>

More information about the swift-evolution mailing list