<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>I believe the reason behind this comes down to the fact that computed values generally won't be used in this way - thus the "computed".</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">var itself isn't a promise that a value is mutable, so much as 'let' is a promise of immutability. If we allowed this, then the compiler must check that each element of the return value is static and will not change, and in that case, why would you not just store the computer value in a true let to begin with, to avoid doing the work over again on each access?</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">It seems a somewhat rare and complicated case for the compiler, for little if any benefit.</div><div id="AppleMailSignature"><br>-Rod</div><div><br>On 11 May 2016, at 11:25 PM, Alexander Momchilov via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">I came an interesting <a href="http://stackoverflow.com/a/37161488/3141234">SO question</a>&nbsp;which&nbsp;pointed out a strange quirk: a computed property must always use the "var" keyword, even if it's read-only, and only referencing other immutable data.<div><br></div><div><pre class="" style="margin-top:0px;margin-bottom:1em;padding:5px;border:0px;font-size:13px;width:auto;max-height:600px;overflow:auto;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;color:rgb(57,51,24);word-wrap:normal;background-color:rgb(239,240,241)"><code style="margin:0px;padding:0px;border:0px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,sans-serif;white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">class</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">Test</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">{</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
  </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">let</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> hello </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">=</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(125,39,39)">"hello"</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
  </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">let</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> world </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">=</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(125,39,39)">"world"</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
  </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">var</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> phrase</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">:</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(43,145,175)">String</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">{ //why must this be 'var'?</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
     </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">return</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">hello </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">+</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)"> </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(16,16,148)">self</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">.</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">world
  </span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">}</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">
</span><span class="" style="margin:0px;padding:0px;border:0px;color:rgb(48,51,54)">}</span></code></pre></div><div>It would be more appropriate for such a read-only, immutable property, to use the "let" syntax, so that its immutability is correctly expressed.<br></div><div><br></div><div>Thoughts?</div></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>