<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div><blockquote type="cite" class=""><div class="">On Jun 28, 2016, at 8:09 AM, Javier Soto via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><div class="">IMO the issue with the argument that we wouldn't be able to "monkey patch" things on sealed classes is that that is already the nature of Swift. The designer of an API can choose to use structs instead of classes, and then there's already no way to "subclass". Moreover, "final" already exists, and whether sealed is introduced or not, and whether it becomes the default or not, API designers are already free to use final in all classes they do not intend to be subclassed, so I think that would be an argument against final existing in the first place, and that ship has already sailed. <br class=""><br class="">As for whether sealed would allow for optimizations: my hunch is that it would. However, as I write this I noticed a flaw with my proposal: I said that sealed classes would be exported as final. This is only half-true. They would in that they can't be subclassed outside the module, but there could be subclasses in the same module! That means if the parent were to be treated as final, code outside the module would incorrectly devirtualize non-final methods. <br class=""></div></blockquote><div><br class=""></div>Also, note that:</div><div>&nbsp; - we're clearly going to have to import ObjC classes as subclassable by default, and in fact there's currently no way to explicitly declare an ObjC class to be final;</div><div>&nbsp; - many classes in ObjC are actually intended to be subclassed (although not every method is intended to be overridden), and those tend to be the classes that users most want to patch;</div><div>&nbsp; - methods in ObjC can just be directly monkey-patched without subclassing, even if we're not necessarily happy about you doing it; and</div><div>&nbsp; - even if we re-implemented a bunch of frameworks in Swift, we'd still have to maintain compatibility with some amount of this stuff.</div><div><br class=""></div><div>So I don't think that sealed-by-default would have any significant impact on the ability to patch Apple code as a third party.</div><div><br class=""></div><div>For code that isn't deployed in an OS that won't be updated, the obviously better solution is to fix the library, either yourself or, if it's closed-source, through your normal vendor support process.</div><div><br class=""></div><div>John.</div><div><br class=""></div><div><blockquote type="cite" class=""><div class=""><div class="gmail_quote"><div dir="ltr" class="">On Tue, Jun 28, 2016 at 7:59 AM Charlie Monroe via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br class="">
&gt; On Jun 28, 2016, at 4:55 PM, Sean Heber via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class="">
&gt;<br class="">
&gt;&gt; On Jun 28, 2016, at 9:52 AM, Mark Lacey via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class="">
&gt;&gt;<br class="">
&gt;&gt;&gt;<br class="">
&gt;&gt;&gt; On Jun 27, 2016, at 9:10 PM, L. Mihalkovic via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:<br class="">
&gt;&gt;&gt;<br class="">
&gt;&gt;&gt; -1 for the fact that if all devs can write working code, fewer can do it in a clear structured fashion that is well designed for extensibility.<br class="">
&gt;&gt;<br class="">
&gt;&gt; This sounds more like an argument for having sealed classes than not. As the proposal points out in the motivation, if the base class is not designed with subclassing in mind then overriding methods can result in unintended behavior (e.g. crashing, or other bugs).<br class="">
&gt;<br class="">
&gt; But I think the counter argument is, what if you need to fix or workaround unintended behavior of the class you’re trying to use?<br class="">
<br class="">
Typically you modify something open source - 99% of which is on GitHub. IMHO the best way is to either fork it and perhaps submit a pull request with the fix.<br class="">
<br class="">
But I understand that this is not always possible...<br class="">
<br class="">
<br class="">
&gt;<br class="">
&gt; l8r<br class="">
&gt; Sean<br class="">
&gt;<br class="">
&gt; _______________________________________________<br class="">
&gt; swift-evolution mailing list<br class="">
&gt; <a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class="">
_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
</blockquote></div><div dir="ltr" class="">-- <br class=""></div><div data-smartmail="gmail_signature" class=""><div dir="ltr" class="">Javier Soto</div></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>