[swift-evolution] [Review] SE-0025 Scoped Access Level

Nicola Salmoria nicola.salmoria at gmail.com
Sat Feb 27 00:46:00 CST 2016


> What is your evaluation of the proposal?

+1

> Is the problem being addressed significant enough to warrant a change to Swift?

I think it addresses a significant omission in the language which deserves to be filled.

> Does this proposal fit well with the feel and direction of Swift?

I think it does.

The emerging pattern in Swift development is to keep type definitions short and focused, and then add additional functionality with extensions.

Extensions therefore become the basic blocks of code in a type. Sometimes they need to contain implementation details which are only relevant to the specific functionality implemented in the extension, and don’t need to bubble up to the surface of the whole type.

Normally when we work in a block between curly braces, everything we declare is local.
When we work between the curly braces of an extension block, however, we don’t have any way to achieve the same behaviour: everything we declare needs to be shared at a minimum with the whole file.

Adding the ‘local’ access level merely reinstates what we take for granted in other parts of the code. It means that as a code maintainer, when I see a ‘local’ entity in an extension I only need to check how it is used inside that extension, rather than in the whole file.

This will become even more important if in the future it will be possible to declare properties inside extensions.

> If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?

I don’t have experience with any other language that uses extensions in such a significant way.

> How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

A quick reading.

—
Nicola



More information about the swift-evolution mailing list