[swift-evolution] Properties on Default Protocol Implementations

Matthew Johnson matthew at anandabits.com
Mon Jan 11 19:27:48 CST 2016


> On Jan 11, 2016, at 7:25 PM, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> On Jan 11, 2016, at 3:46 PM, Trent Nadeau <tanadeau at gmail.com> wrote:
>> 
>> Syntactically, would PwS be special like class-only protocols are now or would it be automatic by having stored property declarations within the protocol?
> 
> Up for debate.  An automatic approach brings hesitation to me, because I don’t want it to be the difference between:
> 
> protocol P {
>  var x : Int { get }
> }
> 
> and:
> 
> protocol P {
>  var x : Int 
> }
> 
> Did I want a PwS there, or did I just forget {get/set}?
> 
> Marking the protocol with an attribute or declmodifier would solve that.

+1.  This is something that deserves to be pretty explicit.

Another point that I think needs to be discussed is whether the protocol storage is just a default that can be overridden or whether it should be protocol-specific.  Or should the protocol author be able to choose.  For example, can a protocol have private storage that is not visible outside the implementation of default or extension methods?  All things that need to be considered IMO.

Matthew

> 
> -Chris
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution



More information about the swift-evolution mailing list