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

Adrian Zubarev adrian.zubarev at devandartist.com
Fri Mar 3 14:37:14 CST 2017

That makes totally sense to me, but thank you John for further clarification.

Adrian Zubarev
Sent with Airmail

Am 3. März 2017 um 21:30:11, John McCall (rjmccall at apple.com) schrieb:

On Mar 3, 2017, at 1:36 PM, Adrian Zubarev via swift-evolution <swift-evolution at swift.org> wrote:
I actually found the source, and it’s even an official one. :)



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 ;)

Note that is arguably not quite true, depending on one's mental model of class properties.

If you think of a class var as being, in essence, an instance property of the class object, then a *stored* class var should be a different variable for each subclass of the class.  That's a reasonable mental model, and it's consistent with the behavior of class methods and so on, for which the Self type changes depending on what class you invoked the method on; but it's not trivial to implement, and it hasn't yet come up to the top of the priority list, which is why we don't currently allow you do define stored class vars.  Anyway, class properties are normally overridable in subclasses, just like class methods; a final class property can't be overridden, but, if stored, under this model it's still a different property for each subclass.

That is conspicuously *not* what a static property of a class is.  A static property of a class is basically a property of *that specific class*; it can be accessed via a subclass but always yields the same variable, which means that in a non-generic context it's essentially a namespaced global.  Now, that's what people want and expect from a static variable on a class, and that's why we implemented it that way, but it's not at all the same thing as "final class".


Adrian Zubarev
Sent with Airmail

Am 3. März 2017 um 18:14:42, Matthew Johnson (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.

swift-evolution mailing list
swift-evolution at swift.org

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

More information about the swift-evolution mailing list