[swift-evolution] [Draft] A Consistent Foundation For Access Control: Scope-Bounded Capabilities

Matthew Johnson matthew at anandabits.com
Fri Mar 3 13:44:27 CST 2017


> On Mar 3, 2017, at 1:26 PM, Adrian Zubarev <adrian.zubarev at devandartist.com> wrote:
> 
> Can you check this translation, and maybe based on it’s (possible) mistakes provide better examples in the next proposal draft on how one should think with the new pure access model.
> 
> open class A {
>      
>     open internal(set) var abc: Int = 42
> 
>     public static func foo() {}
> 
>     open class func bar() {}
> }
> 
> access(inherit, everywhere) class A {
>      
>     access(override, everywhere) access(set, submodule) var abc: Int = 42
This is correct, although it’s worth noting that the `internal(set)` or `access(set, submodule)` is unnecessary.  You’re just re-stating the default availability of the setter.

> 
>     // implicit 'call'
>     access(everywhere) access(override, nowhere) access(type) func foo() {}
> 
>     access(override, everywhere) access(type) func bar() {}
> }

As I noted in my previous reply we’re not going to replace `static` and `class` with this model.  Access control is not the appropriate place to distinguish type vs instance members.

> 
> 
> 
> -- 
> Adrian Zubarev
> Sent with Airmail
> 
> Am 3. März 2017 um 20:12:28, Adrian Zubarev (adrian.zubarev at devandartist.com <mailto:adrian.zubarev at devandartist.com>) schrieb:
> 
>> If I understand the model correctly, then classes structs and enums will have an addition capability for their members.
>> 
>> static = access(type) access(override, nowhere)
>> 
>> class = access(type) access(override, everywhere)
>> 
>> You could combine type into one parameterized access, and make the capability instance the default one, so it will be either or but we don’t have to write instance explicitly like we don’t need it with get.
>> 
>> 
>> 
>> -- 
>> Adrian Zubarev
>> Sent with Airmail
>> 
>> Am 3. März 2017 um 19:36:31, Adrian Zubarev (adrian.zubarev at devandartist.com <mailto:adrian.zubarev at devandartist.com>) schrieb:
>> 
>>> I actually found the source, and it’s even an official one. :)
>>> 
>>> https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Declarations.html#//apple_ref/doc/uid/TP40014097-CH34-ID483 <https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Declarations.html#//apple_ref/doc/uid/TP40014097-CH34-ID483>
>>> NOTE
>>> 
>>> In a class declaration, the static keyword has the same effect as marking the declaration with both the class and final declaration modifiers.
>>> It’s overlapping but you might be able to adjust the behavior to cover that in your model as well ;)
>>> 
>>> 
>>> 
>>> -- 
>>> Adrian Zubarev
>>> Sent with Airmail
>>> 
>>> Am 3. März 2017 um 18:14:42, Matthew Johnson (matthew at anandabits.com <mailto:matthew at anandabits.com>) schrieb:
>>> 
>>>> It would be really helpful if you can find a reference to this somewhere.  If it’s possible to define static in terms of this system also that would be pretty cool.
>>> 
>> 
> 

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


More information about the swift-evolution mailing list