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

Radosław Pietruszewski radexpl at gmail.com
Sat Feb 27 07:50:53 CST 2016


Just a note:

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

The remaining big problem for me in using extensions a lot is the fact that you can’t define stored properties in them. This means I rarely split classes into core and extensions as a means of grouping related stuff, because I want to visually group related methods *and* properties.

I’m not 100% convinced on the proposal just yet, but I think I like the idea. However, without the capability to extend a class with an additional property, the usefulness of `local` is greatly limited.

— Radek

> On 27 Feb 2016, at 07:46, Nicola Salmoria via swift-evolution <swift-evolution at swift.org> wrote:
> 
>> 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
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list