> On 18 Jan 2017, at 05:38, Vinnie Hesener via swift-evolution 
> <swift-evolution@swift.org> wrote:
> 
> The var keyword in protocol property requirements is misleading. 
> 
> From the docs:
> *If a protocol requires a property to be gettable and settable, that property 
> requirement cannot be fulfilled by a constant stored property or a read-only 
> computed property. If the protocol only requires a property to be gettable, 
> the requirement can be satisfied by any kind of property, and it is valid for 
> the property to be also settable if this is useful for your own code.*
> 
> I feel this is slightly confusing. To conform, I can use let for { get }. I 
> can't use var for { get set } if it's computed. This leads me to believe that 
> the keyword var has no actual instructional meaning here. It seems misplaced 
> to represent "property".
> 
> I think it should be something else, or maybe removed entirely? Isn't { get 
> set } enough to describe what this protocol needs? Maybe we can put the { get 
> set } in front of the property name?

-1 from me

I’d rather keep the syntax for protocols as similar as possible to the syntax 
for classes and structs. 

There might be an argument for `let` in a protocol as well as `var` although 
that would really be allowing protocol designers to dictate implementation 
details to designers of structs and classes that implement the protocol.


> 
> I can think of a couple other small benefits of this, but I don't know if it 
> will distract from the main discussion. One of them being that it may 
> discourage using lets for those new to the language, as most people will just 
> lazily copy/paste the declaration. 
> _______________________________________________
> swift-evolution mailing list
> 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