Swift Access Control, Visually

Swift is something like my fiftieth programming language, and I tend to just wash over things like access control, and usually I get away with it. I have to really LIKE a language to pay attention to the mundanities of access control, and it has to be worth it. True in both cases for Swift. True story: I go to Art Basel every year. Year one of Swift, I was too busy enjoying myself sitting in a Starbucks on Lincoln Road working through Swift 1.2 manual to go to the art show or the parties. Anyway: it’s worth it to take a little extra time and think through each of the cases of access control in Swift, because of the subtle differences and specialized meanings that crop up idiomatically. (what on earth is a Public Private(set) and why do you need it?, like that.)

I’ve followed the Swift manual in correlating these diagrams. If you look them up in the manual, you’ll see the entries here in the same order they are in the Swift 4 manual. The intention is to help you visualize the differences, not be a definitive representation that replaces the manual. Feel free to suggest modifications.

This is a work in progress this week and possibly longer.

Class Access Control

Entity Use

Module Access Control

Unit Test Target Access Control

Class Members Access Control

Tuple Access Control

Function Parameters and Return Type Access Control

Enumeration Access Control

Nested Type Access Control

Subclass Access Control

Var, Const, Property, Subscript Access Control

Getter Setter Access Control

need more here on the “Public Private(set)” idiom.

Initializer Access Control

Protocol Access Control

Extension Access Control

Generics Access Control

Typealias Access Control

More Neanderthal DNA markers than 95 % of 23andMe customers. Don’t give me your pro-Cro-Magnon propaganda.