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

Tino Heth 2th at gmx.de
Wed Dec 30 05:47:54 CST 2015

Have you looked at how this is handled in Kotlin?
Imho Jetbrains solution is quite elegant — especially as it also has a natural answer to another problem ("flexible memberwise initialization"; the whole init process is only a short chapter in the docs).
Of course, their approach is different, but I'd rather copy from the best than accept mediocrity because of the not invented here syndrome.

[short explanation: In Kotlin, we would have
class Forwarder(forwardee: Forwardee): P by forwardee {
forwardee would be available as a member, and because it is introduced before the protocol conformance, it can be used there without irritation.
Bonus: The designated initializer is defined at the same time.

As for the implementation:
Why not simply make this feature syntactic sugar and just auto-generate the forwarding methods?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151230/7d437afb/attachment.html>

More information about the swift-evolution mailing list