[swift-evolution] SE-0025: Scoped Access Level, next steps

Russ Bishop xenadu at gmail.com
Mon Mar 14 23:12:17 CDT 2016


> On Mar 14, 2016, at 8:51 PM, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> 
>> On Mar 14, 2016, at 8:36 PM, Patrick Pijnappel via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> Another +1 for James' idea to use private(module), private(file), private:
>> - It avoids ambiguity whether internal/private/local is more restrictive and replaces it with a single axis, public vs. private.
>> - The two longer terms, private(module) and private(file), are the least used ones.
>> - As mentioned by Joe, it admits clean extension to groupings between file and modules in the future (e.g. submodules).
>> 
>> The only question is (as Sean mentioned) how this combines with the syntax for setter access level, e.g. the current private(set). Options:
>> - Unnamed 2nd argument, giving private(file), private(file, set), private(set).
> 
> We could conceivably reskin private(set) too. A lot of people complain it's "weird" as-is, for better or worse.
> 
> -Joe
> 

That’s because it is weird :)

I always thought the computed form should be:

public var whatever: String {
    get { … }
    // override overall visibility to restrict setter
    private set { … }
}


For this proposal you could do something like:

var private set whatever: String = ""



Russ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160314/f7610e6e/attachment.html>


More information about the swift-evolution mailing list