[swift-evolution] class/struct inner member access scope classifier

Ted F.A. van Gaalen tedvgiosdev at gmail.com
Fri Sep 30 12:15:46 CDT 2016


Hi Jeremy and Nevin

Sorry for the delay. quite busy.

As described, the point of my message is that I would like to have the inner members of a class
as default private, that is, not visible in the outer scope and to reveal members (entities)
of the class to the outside world *explicitly* by specifying an access qualifier like
“public” or “internal”, so exactly the other way round as it is now. 
In the current situation I have to precede all declarations which I don’t want to reveal
with “private”. Usually most entities of a class should not be visible outside of it. 
To prevent source breaking one could precede the class definition with a keyword, telling
Swift that all members of a class are private by default like so

closedscope class TG3DGauge: SCNNode
{
    
    var needles = [SCNNode]()  // is now private by default
    var fmtStr = “"            // is now private by default
    
    public var value: CGFloat = 0 // Public!! visible outside class also for “fileprivate" or “internal”  

(as written before)  

If this “closedscope” qualifier is not used things are exactly as it is now.

The “fileprivate” qualifier doen’t need to go so no source breaking here.
I simply stated that I am not really a fan of it.

Kind Regards
Ted



> On 27 Sep 2016, at 10:34, Jeremy Pereira <jeremy.j.pereira at googlemail.com> wrote:
> 
> 
>> On 26 Sep 2016, at 20:58, Ted F.A. van Gaalen via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> Hello! Hope you are all OK! 
>> 
>> 
>> As far as I can see without binoculars, the “fileprivate” acces modifier
>> could be dropped, were it not for source compatibility reasons... 
>> 
>> Unless I am missing something: 
> 
> Yes you are missing something. I, for example have a few cases where it is useful. On the other hand, I was against the change in the meaning of private but, I have to concede that the new meaning is useful. 
> 
> As for dropping file private, why? You don’t have to use it if you don’t want to, so it’s not hurting you. On the other hand, I can use it when I deem it to be the right thing to do. 
> 
> 
>> I don’t want the inner elements
>> of a class (or struct ?) to be visible in outer scope!
>> This is the default case in most OOP languages. 
> 
> The default in Java is package scope. I’m not sure what the default in C++ is, but it’s not private, ditto Javascript. So while that might not be most OOP languages, it probably covers most OOP programs.
> 
> While I think private by default has merit, we are where we are.
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160930/058e2d8d/attachment.html>


More information about the swift-evolution mailing list