<div dir="ltr">Reassigning structures will create new ones. Mutating functions and reassigning its properties won&#39;t: they mutate it.<br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 23, 2015 at 10:51 AM Ian Ynda-Hummel &lt;<a href="mailto:ianynda@gmail.com" target="_blank">ianynda@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I thought structures were immutable and mutating functions actually just created new structures, thus maintaining the by value semantics.<br><div class="gmail_quote"></div><div class="gmail_quote"><div dir="ltr">On Wed, Dec 23, 2015 at 10:45 AM Lino Rosa via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I believe the language would be improved by making structures immutable.</div><div><br></div><div>1) The choice between classes and structures isn’t clear right now. If structures were immutable it would be natural to use them as value objects.</div><div><br></div><div>2) Refactoring a mutable structure into a class when it’s being passed around multiple threads removes the by-value semantics seamlessly. The resulting mutable class isn’t thread-safe.</div><div><br></div><div>2.1) Even when passed around a single thread, the resulting class would be passed by reference, so any mutations would have unintended consequences.</div><div><br></div><div>3) We could probably remove some syntax: `mutating` keyword and variable parameters. Also the `var` keyword before a structure could be used to denote reassignment (not mutability), just as it does with classes.</div><div><br></div><div>Of corse I might not be seeing the whole picture, so please weigh in.</div></div>
</blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=t5fkNsX-2F7-2FAygTFNPNE08PALgkjkO6I8wpsdssDS0uhzD3EyON0qfaM-2BbDYaPGa4azavBvUgXrcfIjbzgpxE8eP9166AITzK3ots1xL7ZbX7ZYqgZjOge2IKsot-2FFjNUORr0LjCExRUPumI8I-2BZoBO7yyqFqYpqCAk5TqOB5aWgB9OMHq0v4txo-2BHeGuoLN9wTozGfCQnGAys309-2B-2Biow4Vc-2FxAZMKOilKYVoGIgGMI-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important">
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div>
</blockquote></div></div>