<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 class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="">&nbsp;I do not understand why you are so much against it</div></div></blockquote><br class=""></div>Data encapsulation is a cornerstone of object oriented programming. Swift has classes, and yet it is impossible to completely hide state / implementation details inside the class. Moreover, it’s impossible to express that something is intended to be completely hidden. Since such a fundamental idea is not supported, there is something fundamentally wrong with the current model.&nbsp;<div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="">Just stop for 10 minutes and think about it…</div></div></blockquote><br class=""></div><div class=""><a href="https://en.wikipedia.org/wiki/Encapsulation_(computer_programming)" class="">https://en.wikipedia.org/wiki/Encapsulation_(computer_programming)</a></div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On Jan 25, 2016, at 4:21 AM, Ondrej Barina &lt;<a href="mailto:obarina@gmail.com" class="">obarina@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">IIya: &nbsp;Private access on file is just fine. I do not understand why you are so much against it. Just stop for 10 minutes and think about it...</div><div class="">Ondrej Barina</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Jan 25, 2016 at 3:54 AM, David Waite via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br class="">
&gt; On Jan 24, 2016, at 1:15 PM, Ilya Belenkiy via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class="">
&gt;<br class="">
&gt;&gt; I think it's possible to believe that your feature would be useful<br class="">
&gt;&gt; without also believing there's something fundamentally wrong with the<br class="">
&gt;&gt; current model, and your arguments make it sound to me like you think<br class="">
&gt;&gt; you're getting a lot more certainty from C++'s "private" than you<br class="">
&gt;&gt; actually are.<br class="">
&gt;<br class="">
&gt;<br class="">
&gt; Data encapsulation is a cornerstone of object oriented programming. Swift has classes, and yet it is impossible to completely hide state / implementation details inside the class. Moreover, it’s impossible to express that something is intended to be completely hidden. Since such a fundamental idea is not supported, there is something fundamentally wrong with the current model. Swift is already a great language, and this issue aside, it’s by far the best language I’ve used. In all other areas Swift does a great job to help the programmer write correct code. This is one weird and very noticeable deviation.<br class="">
<br class="">
</span>Data encapsulation is indeed one of the cornerstone of OO, but every design decision is a trade-off. Is Python not object-oriented because they lack a private keyword, and have the convention of marking internal items with a leading underscore?<br class="">
<br class="">
In addition, it is not possible to completely hide state/implementation details in any language (at least that I have experience with). Java, for instance, will let me use the security manager and RTTI to modify private values, and even has JNI code to modify final values as well (this is how System.out works). There are projects that fundamentally depend on being able to access private fields, such as Spring, partly because the Java standard library tells them to (@Injectable).<br class="">
<br class="">
Even with a “perfect” language mechanism, consumers of the binary will still patch it if they need to in order to get the functionality they want.<br class="">
<br class="">
The best anyone can do is make the breaking of encapsulation an explicit choice. I’m intuiting that you think that writing code into the file where the class was defined is not explicit enough. I feel comfortable saying to my team members that you have to justify adding code next to a class in the same way you would need to justify changing the implementation of that class. The difference between ‘local’ and ‘private’ access is a copy/paste of a function from an extension into the class body within the same file.<br class="">
<br class="">
-DW<br class="">
<div class="HOEnZb"><div class="h5"><br class="">
_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" 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="">
</div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></body></html>