<div dir="ltr">Good point—I hadn't considered the distinction.<div><br></div><div>Does that mean a future version of Swift might allow `let` in a protocol to indicate a value that must be immutable after initialization, such that a computed `var { get }` wouldn't satisfy it?</div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Jan 18, 2017 at 8:48 AM Joe Groff <<a href="mailto:jgroff@apple.com">jgroff@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br class="gmail_msg">
> On Jan 18, 2017, at 8:41 AM, Tony Allevato via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:<br class="gmail_msg">
><br class="gmail_msg">
> Personally, I don't feel that the problem is big enough to warrant a breaking change here.<br class="gmail_msg">
><br class="gmail_msg">
> `var` is the general property declaration keyword in Swift for read-write stored properties and read-only/read-write computed properties. The fact that you can use `let` in place of `var` under one specific circumstance (a read-only property backed by a stored variable) doesn't necessarily make the entire keyword meaningless, IMO. `let` is just a shortcut for a read-only stored property, and I think dropping it or moving `{ get set }` elsewhere would be more confusing, since it would be syntactically inconsistent with how the property is implemented. (Protocol members look the same as class/struct members with the body removed.)<br class="gmail_msg">
><br class="gmail_msg">
> In general, I'm skeptical of ideas that just aim to protect new or bad developers from themselves, especially at the expense of consistency.<br class="gmail_msg">
<br class="gmail_msg">
`let` more strongly guarantees **immutability**, not just "read-only". var { get } indicates that the protocol's interface only lets you read, but provides no guarantee that the implementation can't change the value you get. The language doesn't have the ability to reason about immutability for anything other than stored properties yet, but we want to leave syntactic space for that possibility without muddying the strong guarantee of `let`. For that reason, protocols only support `var { get }` requirements today. `let` properties naturally model the requirement since you can read them; their interface is a superset of the protocol requirement.<br class="gmail_msg">
<br class="gmail_msg">
-Joe<br class="gmail_msg">
</blockquote></div>