[swift-evolution] [Proposal] Revising access modifiers on extensions

Jose Cheyo Jimenez cheyo at masters3d.com
Tue Jun 28 15:55:16 CDT 2016


> On Jun 28, 2016, at 12:40 PM, Adrian Zubarev via swift-evolution <swift-evolution at swift.org> wrote:
> 
> How do private or fileprivate help extensions in general?
> 
https://github.com/apple/swift-evolution/blob/master/proposals/0025-scoped-access-level.md <https://github.com/apple/swift-evolution/blob/master/proposals/0025-scoped-access-level.md>

> Is really laziness a strong argument over consistency and clarity? 
> 
> 

What does ‘lazy’ have to do with anything in this proposal? Im confused. 

I know that your desire is to make it consistent and thus clear but the reality is that 
this proposal ( and `group` ) would just make the language complex and really confusing. 


> As for your example I’d have a pretty good solution (I can’t say this will be accepted, but the idea is great, at least I think that way. I’d propose for that feature after Swift 3 drops):
> 
> // Use correct consistent access control
> fileprivate extension Int {
>      
>     // every member of a nameless group would be `fileprivate`
>     fileprivate group {
>      
>        func double() -> Int {
>            return self*2
>        }
>         
>        func member1() {}
>        func member2() {}
>        func member3() {}
>        func member4() {}
>     }
> }
> A group could do way more than just in this example: https://gist.github.com/DevAndArtist/c74f706febf93452999881335f6ca1f9 <https://gist.github.com/DevAndArtist/c74f706febf93452999881335f6ca1f9>
> We’d move the behavior out into its own more powerful feature.
> 
> 
> 
> 
> -- 
> Adrian Zubarev
> Sent with Airmail
> 
> Am 28. Juni 2016 um 03:14:08, Jose Cheyo Jimenez (cheyo at masters3d.com <mailto:cheyo at masters3d.com>) schrieb:
> 
>> I would be against removing access modifiers on extensions. I actually don't see anything wrong with the way extensions work with modifiers right now.  Consistency for consistency's sake is never a good measurement if it is not addressing a pain point. 
>> 
>> When ever I extend a swift standard type, I always make it "fileprivate" because I don't want to pollute autocomplete for that type. 
>> 
>> fileprivate extension Int {
>>    func double() -> Int {
>>        return self*2
>>    }
>> }
>> 
>> My understanding is that private / fileprivate was renamed/introduced to help with extensions. I don't think extensions need anymore complexities. I would hardly ever use private in swift 3 for example (when it gets implemented.)
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160628/b9f1beb6/attachment-0001.html>


More information about the swift-evolution mailing list