<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Point taken. I think Swift supports both styles reasonably well. Initially it looked like writing the 'with' function would be troublesome but it turned out to be quite simple.</div><div class=""><br class=""></div><div class="">I appreciate the point you're making, which is that you get much of the value of purely immutable values with Swift's mutable structures + value semantics + let constant structs. And, you also get a simpler implementation in some cases (e.g. not needing functions like 'with').</div><div class=""><br class=""></div><div class="">Swift has a pretty interesting model here that seems to capture some of the best parts of the imperative and immutable/functional styles. For example, I had to check whether this worked as expected:</div><div class=""><br class=""></div><div class="">```</div><div class="">struct&nbsp;Person {<br class="">&nbsp; &nbsp;&nbsp;var&nbsp;name:&nbsp;String<br class="">&nbsp; &nbsp;&nbsp;var&nbsp;address:&nbsp;String<br class="">}<br class=""><br class="">class&nbsp;C {<br class="">&nbsp; &nbsp;&nbsp;private(set)&nbsp;var&nbsp;currentPerson =&nbsp;Person(name:&nbsp;"Andy", address:&nbsp;"1 Battery St")<br class="">}<br class=""><br class="">func&nbsp;f() {<br class="">&nbsp; &nbsp;&nbsp;let&nbsp;instance =&nbsp;C()<br class="">&nbsp; &nbsp;&nbsp;instance.currentPerson.name =&nbsp;"Dave" &nbsp; // Cannot assign to property: 'currentPerson' setter is inaccessible<br class="">}</div><div class="">```<br class=""><br class=""></div><div class="">This means the implementation of class C can set the currentPerson and its properties, but the currentPerson is immutable to the outside. A similar thing could be accomplished with an immutable Person, but you still need to use private(set), so it's no more complicated or risky to use the mutable Person.</div><div class=""><br class=""></div><div class="">The difference is mostly one of style, way of thinking, and psychology. For some people seeing the declaration of Person having vars is uncomfortable if they are used to a functional style. "If I have a Person, will it be changed unexpectedly out from under me?" For people who know Swift well, the fact that it's a struct means any potential change to Person can only happen under controlled circumstances like an inout parameter, and only if I declare it a var. This discussion was very helpful for me to understand the nuances of struct better.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class=""><br class=""></div><div class="">Andy</div><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 22, 2016, at 7:01 AM, Matthew Johnson &lt;<a href="mailto:matthew@anandabits.com" class="">matthew@anandabits.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Yes, this is true. &nbsp;However, this thread is about improving the convenience of immutable structs / functional code. &nbsp;It is quite common in such code that the previous value is no longer needed. &nbsp;I am encouraging people to focus on what the real benefits of this style is (value semantics) and how the same benefit might be achieved in a different way in a hybrid language like Swift.</div></div></blockquote></div><br class=""></body></html>