Re: access modifiers in protocols
Re: access modifiers in protocols
- Subject: Re: access modifiers in protocols
- From: Roland King <email@hidden>
- Date: Wed, 17 Jun 2015 13:24:08 +0800
> On 17 Jun 2015, at 13:15, Quincey Morris <email@hidden> wrote:
>
> The rest of your explanations is TMI, I can’t wrap my brain around it, but why can’t you do this:
>
>> public protocol Foo
>> {
>> mutating func foo( Int )->Void
>> }
>>
>> internal protocol FooImplementedWithArray : Foo
>> {
>> var bar : Array<Int> { get set }
>> }
>>
>> extension FooImplementedWithArray
>> {
>> public mutating func foo( i : Int ) -> Void { bar.append( i ) }
>> }
>
> and have individual types conform to Foo or FooImplementedWithArray, depending on which default implementation you want?
>
Two reasons, which were in the chunk of text which was TL;DR (couldn’t make it shorter), I tried this and lots of other things
1) making FooImplementedWithArray internal downgrades the foo() function to internal within that protocol, no longer is it public (this is made explicit by a compiler warning which tells you you’re implementing an internal function as public if you try doing it)
2) anything implementing FooImplementedWithArray can at *most* be internal, you can’t have a public class implement an internal protocol
So that doesn’t give me what I need.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden