<div dir="ltr">A second try at improving syntax for properties, aiming for unification and consistency. This time I suggest to declare initialValue as an accessor, as it is really an accessor with shorthand syntax. For this and a couple of other ideas, please see <a href="https://gist.github.com/Anton3/f71a3e2ee29dffe1b9b2">the gist</a>.</div><div class="gmail_extra"><br><div class="gmail_quote">2016-02-14 15:41 GMT+03:00 Taras Zakharko <span dir="ltr"><<a href="mailto:taras.zakharko@uzh.ch" target="_blank">taras.zakharko@uzh.ch</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You are right! Ok, I’m convinced now as far as that goes :) Smart design. I didn’t think that far, I’m afraid.<br>
<br>
Thanks for explaining again,<br>
<br>
T.<br>
<div class="HOEnZb"><div class="h5"><br>
> On 14 Feb 2016, at 13:33, Brent Royal-Gordon <<a href="mailto:brent@architechies.com">brent@architechies.com</a>> wrote:<br>
><br>
>> This means that t1 and t2 should get two different initial values which is probably not what one would have intended.<br>
><br>
> On the contrary, that's how initial values always work in Swift. Try it yourself: if you copy that code sample, delete the `[custom]`, and paste it into a Swift REPL (any version, as far as I know), it will print "2" and "3".<br>
><br>
> This semantic is important in several cases, like assigning unique IDs, but it's perhaps most crucial when you're initializing with a reference type. When you write something like this:<br>
><br>
> struct Foo {<br>
> let bar = NSMutableArray()<br>
> }<br>
><br>
> Each `Foo` needs to get its own, separate instance of NSMutableArray, rather than all of them sharing a single array. Reevaluating the initial value for every initialization achieves that goal.<br>
><br>
> Given that it's the way the rest of the language works, I really don't think it'll be particularly surprising if this semantic carries over to property behaviors, too.<br>
><br>
> --<br>
> Brent Royal-Gordon<br>
> Architechies<br>
><br>
<br>
</div></div></blockquote></div><br></div>