[swift-evolution] Analysis of existing scopes

Joanna Carter joanna at carterconsulting.org.uk
Sat Feb 25 04:35:24 CST 2017


> Le 25 févr. 2017 à 02:55, Xiaodi Wu <xiaodi.wu at gmail.com> a écrit :
> 
> It is a useful generalization of an absolutely obligatory feature for new `private`. Consider the following:
> 
> ```
> private class Foo {
>   private class Bar {
>     /* blank */ class Baz { }
>   }
> }
> ```
> 
> What access modifier can be used in place of `blank` to make `Foo.Bar.Baz` have the same visibility as `Foo.Bar`? Note that `private` inside the type is more restrictive than `private` in the declaration of the type; the precise visibility of `Foo.Bar` is not expressible inside `Foo.Bar` itself. To allow `Foo.Bar.Baz` to be visible everywhere that `Foo.Bar` is visible, we must allow `blank` to be replaced by a modifier other than `private`.

Aaaarrrgghhh!!! Of course!

You'd have thought, having created massive frameworks in C#, which allows the same thing, and which I used extensively, I would have remembered that.

It just goes to show that we can often be so close to a subject that we "can't see the wood for the trees" :-)

--
Joanna Carter
Carter Consulting



More information about the swift-evolution mailing list