> On Feb 17, 2017, at 9:29 AM, Slava Pestov <spes...@apple.com> wrote:
> 
> 
>> On Feb 17, 2017, at 12:09 AM, Charlie Monroe via swift-evolution 
>> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>> 
>> True, what I meant was a wider feedback - let's face it, there are many more 
>> Swift developers now than 2 years ago.
>> 
>> My objection is not to the documentation itself, but to the fact that I'm 
>> unnecessarily exposing an internal implementation detail to the rest of the 
>> module. Being able to hide it from the rest IMHO leads to better 
>> though-through API that is indeed meant to be exposed; whereas exposing 
>> internal details leads to allowing various quick hacks instead. We know 
>> these quick hacks very well from the ObjC world by accessing private parts 
>> of the object via duck typing or setting values via KVO.
>> 
>> At least this is my experience with which the less implementation details 
>> are exposed to the outer world, the better.
> 
> I think the fundamental disagreement we’re seeing in this thread is the 
> meaning of “outer world”; to some, it means “users of your module”. To 
> others, it also means “other developers on my team who are working on other 
> files in the module”.

I've come across projects where multiple developers contributed to the project 
over the time, some leaving the company, some coming, thus inheriting the 
project. Those that came to the project at later stages (with the project being 
larger) often tried to use the path of least resistance when fixing 
issues/adding new features, which often resulted in hack-ish code that accessed 
members that were meant to be private to the class but weren't since the 
members were used by subclasses/extensions in other files, etc. (things 
solvable by extensions).

If these members were protected, the developer wouldn't be able to access them 
and it would encourage a discussion on why the member is protected and if there 
is a "cleaner" way to do this. That's why I'm saying that the correct access 
control encourages cleaner code and better public APIs. Even when "public" 
means "internal" (as in within one module).

I totally agree that it's a lot depending on the team and the people, but you 
can't always control everyone all the time and that's where the language should 
help and guide.

> 
> Personally I feel enforced encapsulation of implementation detail to the 
> latter group is less important than the former, and can be handled by 
> convention. Whereas other users of your module definitely benefit from access 
> control and being able to consume a clearly-defined interface.
> 
> Slava
> 
>> 
>>> On Feb 17, 2017, at 8:54 AM, Xiaodi Wu <xiaodi...@gmail.com 
>>> <mailto:xiaodi...@gmail.com>> wrote:
>>> 
>>> That blog post starts out right away to say that it's a response to 
>>> community feedback. Moreover, the scenario you describe was just as 
>>> possible in 2014 as it is now. Finally, then as now, it's unclear why you 
>>> consider documentation to be "not pretty." After all, your reader would 
>>> need to consult the documentation before using a variable anyway.
>>> On Fri, Feb 17, 2017 at 01:04 Charlie Monroe via swift-evolution 
>>> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>>> I'm aware of this, but that's fairly a long time ago - before Swift was 
>>> open source and had community feedback and before Swift was used widely 
>>> among developers.
>>> 
>>> To me, real-world use of the language has shown some flaws of missing a 
>>> protected access control, mainly having to decide between having a variable 
>>> internal or cramming all of the class extension into one file, making it a 
>>> 3KLOC mess. Either solution is not pretty - now I have it split among 
>>> several files with an internal variable commented as "Do not use, for 
>>> private use of this class only."
>>> 
>>>> On Feb 17, 2017, at 7:47 AM, Jose Cheyo Jimenez <ch...@masters3d.com 
>>>> <mailto:ch...@masters3d.com>> wrote:
>>>> 
>>>> https://developer.apple.com/swift/blog/?id=11 
>>>> <https://developer.apple.com/swift/blog/?id=11>
>>>> 
>>>> 
>>>> 
>>>> On Feb 16, 2017, at 10:05 PM, Charlie Monroe via swift-evolution 
>>>> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>>>> 
>>>>> How about removing fileprivate, getting Swift 2 meaning of private (as 
>>>>> most people here now suggest) and add additional @protected annotation 
>>>>> for those who want a more fine-grained solution:
>>>>> 
>>>>> @protected private - members accessable only from the 
>>>>> class/struct/enum/... and their extensions within the file
>>>>> 
>>>>> @protected internal - again, but you can access it even from extensions 
>>>>> and subclasses outside of the file within the entire module.
>>>>> 
>>>>> @protected public/open - the same as above, but outside the modules.
>>>>> 
>>>>> To me, this way most people here will be happy:
>>>>> 
>>>>> - those wishing the access control gets simplified - it in fact does, you 
>>>>> don't need to use @protected, if you don't want to/need to.
>>>>> - those who need a fine-grained solution, here it is.
>>>>> 
>>>>> 
>>>>> 
>>>>>> On Feb 17, 2017, at 3:49 AM, Matthew Johnson via swift-evolution 
>>>>>> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> Sent from my iPad
>>>>>> 
>>>>>>> On Feb 16, 2017, at 8:36 PM, David Sweeris via swift-evolution 
>>>>>>> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>>>>>>> 
>>>>>>> 
>>>>>>>> On Feb 16, 2017, at 14:34, Slava Pestov via swift-evolution 
>>>>>>>> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>>>>>>>> 
>>>>>>>> While we’re bikeshedding, I’m going to add my two cents. Hold on to 
>>>>>>>> your hat because this might be controversial here.
>>>>>>>> 
>>>>>>>> I think both ‘private’ and ‘fileprivate’ are unnecessary complications 
>>>>>>>> that only serve to clutter the language.
>>>>>>>> 
>>>>>>>> It would make a lot more sense to just have internal and public only. 
>>>>>>>> No private, no fileprivate, no lineprivate, no protected. It’s all 
>>>>>>>> silly.
>>>>>>> 
>>>>>>> Eh, I've used `private` to keep myself honest in terms of going through 
>>>>>>> some book-keeping functions instead of directly accessing a property.
>>>>>> 
>>>>>> This is exactly the kind of thing I like it for and why I hope we might 
>>>>>> be able to keep scoped access even if it gets a new name that ends up as 
>>>>>> awkward as fileprivate (allowing private to revert to the Swift 2 
>>>>>> meaning).
>>>>>> 
>>>>>>> 
>>>>>>> - Dave Sweeris
>>>>>>> _______________________________________________
>>>>>>> swift-evolution mailing list
>>>>>>> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
>>>>>>> https://lists.swift.org/mailman/listinfo/swift-evolution 
>>>>>>> <https://lists.swift.org/mailman/listinfo/swift-evolution>
>>>>>> 
>>>>>> _______________________________________________
>>>>>> swift-evolution mailing list
>>>>>> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
>>>>>> https://lists.swift.org/mailman/listinfo/swift-evolution 
>>>>>> <https://lists.swift.org/mailman/listinfo/swift-evolution>
>>>>> 
>>>>> _______________________________________________
>>>>> swift-evolution mailing list
>>>>> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
>>>>> https://lists.swift.org/mailman/listinfo/swift-evolution 
>>>>> <https://lists.swift.org/mailman/listinfo/swift-evolution>
>>> 
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
>>> https://lists.swift.org/mailman/listinfo/swift-evolution 
>>> <https://lists.swift.org/mailman/listinfo/swift-evolution>
>> 
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to