<div dir="ltr"><div><div>I don’t understand how extensions help with code locality. It’s literally a matter of <i>curly braces</i>. I already glue the extension block to the bottom <span style="font-family:monospace,monospace">}</span> of the protocol block anyway by omitting the empty linebreak.<br><br><span style="font-family:monospace,monospace">protocol Protocol<br>{<br>    func default_function()<br>}<br>extension Protocol<br>{<br>    func default_function()<br>    {<br>    }<br>}</span><br><br></div>as opposed to <br><br><span style="font-family:monospace,monospace">protocol Protocol<br>{<br>    func default_function()<br>    {<br>    }<br>}</span><br><br></div>I would very much appreciate not having to retype <span style="font-family:monospace,monospace">Protocol</span> and <span style="font-family:monospace,monospace">default_function()</span> over and over. The whole cult-of-same-file-extensions seems to be people refusing to let go of old C++ habits. Have you noticed that nowhere else in Swift is there a concept of separating type declarations from type definitions? That’s because people managed to figure out that typing the same words over and over again doesn’t actually keep code neater at all.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 2, 2017 at 11:27 AM, Gor Gyolchanyan <span dir="ltr">&lt;<a href="mailto:gor.f.gyolchanyan@icloud.com" target="_blank">gor.f.gyolchanyan@icloud.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><span class=""><blockquote type="cite"><div>On Aug 2, 2017, at 6:15 PM, Taylor Swift &lt;<a href="mailto:kelvin13ma@gmail.com" target="_blank">kelvin13ma@gmail.com</a>&gt; wrote:</div><br class="m_-1874922364890104218Apple-interchange-newline"><div><div dir="ltr"><div><div>I agree with this, extensions on types defined in the same file are generally silly, and default implementations belong in the protocol body. I don’t agree with certain style guides prescription of same-file extensions; they should only be used to hide protocol conformances that are “unimportant” to the functionality of the type. In practice this means only conformances like <span style="font-family:monospace,monospace">CustomStringConvertible</span> and <span style="font-family:monospace,monospace">CustomDebugStringConvertible</span> live in extensions.<br><br></div>If you want to group related methods, use linebreaks and whitespace for that. Don’t split up the type braces since that messes up the whole one-set-of-braces == one type definition visual rule.<br><br></div>The only time it ever makes sense to extend a non concrete type that you own is when adding conditional default implementations. Having to extend a bare protocol is the product of a language limitation.</div></div></blockquote><div><br></div></span><div>Take a look at my replies to Tino Heth about code locality and the rest...</div><span class=""><br><blockquote type="cite"><div><div class="gmail_extra"><div class="gmail_quote">On Wed, Aug 2, 2017 at 6:26 AM, Tino Heth via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><span><br><blockquote type="cite"><div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">That would work as well, but it has the downside of forcing a potentially huge number of methods to be implemented in a single place, reducing the readability as opposed to packing them into semantically related groups in the form of extensions.</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"></div></blockquote></span><div>I really don&#39;t get why people are so obsessed with same-file extensions:<div>They are recommended in style guides, influencers blog about them, and they motivated a ridiculous complex change in the access rights system. Yet I haven&#39;t seen any evidence that they offer real benefit.</div><div>Extensions are great for adding useful helpers to existing types, and still allow you to selectively expose details of your own classes — but most people seem to ignore those options and focus on something can be done better with plain old comments.</div><div>[sorry for the rant — but I think a critical look at extensions is long overdue: I rarely see someone questioning their role, so basically, we are making important decisions based on pure superstition]</div><div><br></div><div>A protocol itself is already a vehicle to group related methods, and if you have a huge entity, it doesn&#39;t get better just because you split it and hide its complexity.</div></div><span><br><blockquote type="cite"><div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">Also, please include the original message for reference purposes.</span></div></blockquote></span></div>[hopes Discourse will happen soon ;-) ]</div><br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>
</div></blockquote></span></div><br></div></blockquote></div><br></div>