<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">I already see the problem here:</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">class A { var x: Int { return 42 } }</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">class B: A { override let x = 7 } // assume that will work</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">class C: B { override var x: Int { /* wait this wont work anymore */ } }</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">You won’t be able to override an immutable constant.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;">I don’t like such a change.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div> <div id="bloop_sign_1461439398754067968" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">-- <br>Adrian Zubarev<br>Sent with Airmail</div></div> <br><p class="airmail_on">Am 23. April 2016 bei 21:19:27, Roman Zhikharevich via swift-evolution (<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>) schrieb:</p> <blockquote type="cite" class="clean_bq"><span><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div></div><div>
<title></title>
I think, it could be a good idea to make computed properties
overridable with let constants.
<div class=""><br class=""></div>
<div class="">Something like this:</div>
<div class=""><br class=""></div>
<div class="">
<div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(131, 148, 150);" class="">
<div style="margin: 0px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #859901" class="">class</span> <span style="font-variant-ligatures: no-common-ligatures" class="">Parent
{</span></div>
<div style="margin: 0px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> </span> <span style="font-variant-ligatures: no-common-ligatures; color: #859901" class="">var</span> <span style="font-variant-ligatures: no-common-ligatures" class="">x:</span>
<span style="font-variant-ligatures: no-common-ligatures; color: #859901" class="">Int</span> <span style="font-variant-ligatures: no-common-ligatures" class="">{</span></div>
<div style="margin: 0px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> </span> <span style="font-variant-ligatures: no-common-ligatures; color: #859901" class="">let</span> <span style="font-variant-ligatures: no-common-ligatures" class="">x =</span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29a198" class="">42</span></div>
<div style="margin: 0px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> </span> <span style="font-variant-ligatures: no-common-ligatures; color: #586e75" class=""><i class="">/*</i></span></div>
<div style="margin: 0px; line-height: normal; color: rgb(88, 110, 117);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><i class=""> * Compute
x...</i></span></div>
<div style="margin: 0px; line-height: normal; color: rgb(88, 110, 117);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><i class="">
*/</i></span></div>
<div style="margin: 0px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> </span> <span style="font-variant-ligatures: no-common-ligatures; color: #859901" class="">return</span> <span style="font-variant-ligatures: no-common-ligatures" class="">x</span></div>
<div style="margin: 0px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div>
<div style="margin: 0px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div>
<div style="margin: 0px; line-height: normal; : 14px;" class=""><br class=""></div>
<div style="margin: 0px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures; color: #859901" class="">class</span> <span style="font-variant-ligatures: no-common-ligatures" class="">Child:</span> <span style="font-variant-ligatures: no-common-ligatures; color: #b58901" class="">Parent</span> <span style="font-variant-ligatures: no-common-ligatures" class="">{</span></div>
<div style="margin: 0px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> </span> <span style="font-variant-ligatures: no-common-ligatures; color: #586e75" class=""><i class="">/*</i></span></div>
<div style="margin: 0px; line-height: normal; color: rgb(88, 110, 117);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><i class=""> * Sometimes you need to
override computed properties with simple
constants.</i></span></div>
<div style="margin: 0px; line-height: normal; color: rgb(88, 110, 117);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><i class=""> * This is currently done
like this.</i></span></div>
<div style="margin: 0px; line-height: normal; color: rgb(88, 110, 117);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><i class=""> */</i></span></div>
<div style="margin: 0px; line-height: normal; color: rgb(88, 110, 117);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #839496" class=""> </span> <span style="font-variant-ligatures: no-common-ligatures" class=""><i class="">//override var x: Int {return 7}</i></span></div>
<p style="margin: 0px; line-height: normal; : 14px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><br class="webkit-block-placeholder"></p>
<div style="margin: 0px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class=""> </span> <span style="font-variant-ligatures: no-common-ligatures; color: #586e75" class=""><i class="">/*</i></span></div>
<div style="margin: 0px; line-height: normal; color: rgb(88, 110, 117);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><i class=""> * But this looks
neater.</i></span></div>
<div style="margin: 0px; line-height: normal; color: rgb(88, 110, 117);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><i class=""> * Currently this gives
"error: cannot override with a stored property
'x'".</i></span></div>
<div style="margin: 0px; line-height: normal; color: rgb(88, 110, 117);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><i class=""> */</i></span></div>
<div style="margin: 0px; line-height: normal; color: rgb(133, 153, 1);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #839496" class=""> </span> <span style="font-variant-ligatures: no-common-ligatures" class="">override</span> <span style="font-variant-ligatures: no-common-ligatures" class="">let</span>
<span style="font-variant-ligatures: no-common-ligatures; color: #839496" class="">x =</span> <span style="font-variant-ligatures: no-common-ligatures; color: #29a198" class="">7</span></div>
<div style="margin: 0px; line-height: normal;" class="">
<span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div>
</div>
</div>
_______________________________________________<br>swift-evolution mailing list<br>swift-evolution@swift.org<br>https://lists.swift.org/mailman/listinfo/swift-evolution<br></div></div></span></blockquote></body></html>