[swift-evolution] Default access control / Access control blocks

Dan Raviv dan.raviv at gmail.com
Tue Mar 29 09:07:41 CDT 2016


Hi,

While implementing a function which returns a struct as a result, I ran
into having to make not only the struct public but also its members,
otherwise external callers are exposed to the struct but not to its members.

1) Wouldn't it make sense for a public struct to have its fields be public
by default? Individual fields's access could still be overridden as
internal.

2) If the answer to 1 is no, does it make sense to have to specify the
access level for each individual field which shouldn't have default access
level? Why not have an access control block, e.g.

public struct Result {
    public {
        field1: Double
        field2: Int
    }
}

Please excuse me if similar functionality already exists and I'm not aware.

Thanks,
Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160329/f258706e/attachment.html>


More information about the swift-evolution mailing list