[swift-evolution] Make access control private by default.
Leonardo Pessoa
me at lmpessoa.com
Mon May 23 17:43:36 CDT 2016
I was just about to mention this too. I think it's interesting that
one can write a simple application in Swift without having to worry
(much) about visibility of elements. Please note I'm talking about
applications not frameworks.
I also agree this is good for teachability because you can worry about
more important aspects of programming (functionality and structure)
than just the correct visibility (that makes no difference to a
student until they move to coding a framework themselves). I
understand Knut's point in clarity but that's the same with the
languages mentioned and many more: one visibility is the default in
each language and as developers we have to understand and know that
for our language of choice and we shouldn't be required anything more
explicit than that (you're not required in Java to declare defaults).
But I also agree that, to some extent, private may not make sense if
the default visibility is already not visible outside the current
module but should that be an excuse to just drop it? I, on the other
hand, miss the protected visibility but I understand it's lack
conforms to the programming model proposed for the language (I know I
should use delegates instead of it).
So, in my opinion, if anything is to be changed regarding visibility
it would be to drop the private visibility at all but not change the
default visibility to private because only what is visible outside
(public) is what matters to be declared, right?
On 23 May 2016 at 18:45, Jean-Daniel Dupas via swift-evolution
<swift-evolution at swift.org> wrote:
>
>> Le 23 mai 2016 à 23:21, Knut Lorenzen via swift-evolution <swift-evolution at swift.org> a écrit :
>>
>>
>>> On 19 May 2016, at 19:18, John McCall <rjmccall at apple.com> wrote:
>>>
>>> That is not at all true. The dynamic OOP languages do not, as a rule, have any access control at all. Java and C# default to package access, which is analogous to internal. C++ is, as always, complicated and different.
>>
>> Class members are private by default in both Java and C#. As are ivars and selectors in Objective-C (the latter having to be redeclared in the header file for module-wide access). Swift definitely gives greater default scope to class members in comparison to other OOP languages.
>
> On Java, they are package-private, not private by default, which is closer to module visibility of swift than private.
>
>
>>
>> Knut
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
More information about the swift-evolution
mailing list