[swift-evolution] [Review] SE-0169: Improve Interaction Between private Declarations and Extensions

Gwendal Roué gwendal.roue at gmail.com
Tue Apr 11 09:20:31 CDT 2017


> Le 8 avr. 2017 à 00:45, Jordan Rose <jordan_rose at apple.com> a écrit :
> 
> 
>> On Apr 7, 2017, at 04:18, Gwendal Roué via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> - the private/fileprivate qualifier used not to be a intrinsic property of an object (because one had to move from private to fileprivate as soon as an extension was added). Now private/fileprivate can be made meaningful, and above all *stable*. A scenario where private is turned into a fileprivate now involves something called "friendship" in C++: fileprivate now reflects *actual design intent*, not "shut up this stupid compiler".
> 
> I, uh, wish to object to your implication that C++ 'friend' reflects actual design intent in most cases. :-)

I have used C++ `friend`, like 15 years ago, and I can't say I lack it today!

Still, under this proposal, Swift's `fileprivate` will cover some use cases of C++ `friend`, and also `protected`: after all, some blessed types or subclasses will have access to some otherwise unavailable members. If I'm right, we should see "Swift fileprivate considered harmful" posts sooner or later :-)

BTW - I've just realized that I've voted twice on this proposal - apologies!

Gwendal



More information about the swift-evolution mailing list