<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I’m confused by your example below. Your move() function is equivalent to this:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Menlo" class="">func&nbsp;move(position:&nbsp;Position) {</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;var&nbsp;copy = position</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; copy.x&nbsp;+=&nbsp;20</font></div><div class=""><font face="Menlo" class="">}</font></div></blockquote><div class=""><br class=""></div><div class="">Did you mean “var” there? (sidenote: var is being removed from the function call site)</div><div class=""><br class=""></div><div class="">Structs are immutable. It’s only with a var-declaration and a mutating function or it’s exposed properties, or the passing via inout, that structs appear to become immutable, but even that is a copy-on-write behavior. Like others have mentioned, the optimizer can remove this copy in many places for efficiency gains.</div><div class=""><br class=""></div><div class="">For instance, this is how you would change the incoming struct:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Menlo" class="">func&nbsp;move(inout&nbsp;position:&nbsp;Position) {</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp;&nbsp;position.x&nbsp;+=&nbsp;20</font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">var&nbsp;p1 =&nbsp;Position(x:&nbsp;10, y:&nbsp;10)<br class="">move(&amp;p1)</font></div></blockquote><div class=""><br class=""></div><div class="">This will print 30 both with struct or class.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">1) The&nbsp;choice between classes and structures isn’t clear right now. If structures were immutable it would be natural to use them as value objects.<br class=""></blockquote></div><div class=""><br class=""></div><div class="">If you have a value-type type and it supports equality, then a struct is the “right” choice. That’s the basic guideline. So anything you wish to treat as a value and have value-semantics (which is basically copy-on-write), use a struct. That seems like what you are saying, and that’s already the case.</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">2) Refactoring a mutable structure into a class when it’s being passed around multiple threads removes the by-value semantics seamlessly. The&nbsp;resulting mutable class isn’t thread-safe.</blockquote></div><div class=""><br class=""></div><div class="">Classes, by definition, remove value-semantics. I agree that this type of refactoring is inherently fragile, but I don’t see how having “immutable” structs changes this.&nbsp;</div><div class=""><br class=""></div><div class="">-David</div><br class=""></body></html>