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

Dmitri Gribenko gribozavr at gmail.com
Mon Feb 29 04:30:24 CST 2016


On Sun, Feb 28, 2016 at 11:55 AM, Nate Cook via swift-evolution
<swift-evolution at swift.org> wrote:
>> On Feb 28, 2016, at 12:17 PM, Joe Groff via swift-evolution <swift-evolution at swift.org> wrote:
>>
>> Nate Cook via swift-evolution
>> <swift-evolution at swift.org> wrote:
>>
>>> For another example, see this comment in the standard library, which says
>>> not to use the _variantStorage property, then scroll down about twenty >
>>> lines to see it used:
>>>      https://github.com/apple/swift/blob/master/stdlib/public/core/HashedCollections.swift.gyb#L432
>>>
>>> As a reader of this file, what should be my interpretation here? (a) The
>>> init that uses _variantStorage just got put in the wrong place, (b) the
>>> init should've been written without using _variantStorage, or (c) the
>>> comment is outdated? Marking _variantStorage as scoped and closing the
>>> initial declaration block of the type would both communicate and enforce the actual intent.
>>
>> The standard library can't take advantage of private access control yet
>> because of the way its implementation is fully serialized and exposed to
>> every program. It's not a great example of how access control ought to be
>> used.
>
> Understood! And I should clarify that I'm not proposing a change or pointing out a defect within the standard library,

This is a defect in the standard library.  That code shouldn't use
_variantStorage, or, if it needs to, it should be moved above the
comment, and we need to add a lot of tests for it (as comment says).

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the swift-evolution mailing list