[swift-evolution] Figuring out what you get for free

Félix Cloutier felixcloutier at icloud.com
Tue Sep 12 11:13:48 CDT 2017


If you look at the source for Sequence <https://github.com/apple/swift/blob/master/stdlib/public/core/Sequence.swift#L325>, you can see that the protocol declares a ton of methods and properties; but in fact, all you need to provide is Element, Iterator and makeIterator. The rest comes for free, but can be specialized.

Of course, I don't want to work more than I need to. However, I find that I'm having trouble figuring out what I get for free when I implement a protocol. In principle, I like conditional conformances and synthesized implementation of protocol methods, but I find that they both make it harder to figure out what I need to implement, and what are going to be the performance characteristics of methods that I choose to not implement.

I feel like this is perceived to be a problem by a lot of other people. Is there anything that can make it easier to figure out what you get for free?

Félix
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170912/f105e01d/attachment.html>


More information about the swift-evolution mailing list