<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 23, 2015, at 10:37 AM, Lino Rosa &lt;<a href="mailto:lino.aguiar.rosa@gmail.com" class="">lino.aguiar.rosa@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><span class="" style="font-weight: bold; white-space: nowrap; line-height: 1.5;">Paul Cantrell:&nbsp;</span>Sure, example below. Changing `struct Position` into `class Position` would still compile and print 30 instead.&nbsp;</div><div class=""><div class=""><div class=""><br class=""></div><div class="">======<span style="line-height:1.5" class="">======</span><span style="line-height:1.5" class="">======</span><span style="line-height:1.5" class="">======</span><span style="line-height:1.5" class="">======</span><br class=""></div><div class=""><div class="">struct Position {</div><div class="">&nbsp; var x: Int</div><div class="">&nbsp; var y: Int</div><div class="">&nbsp;&nbsp;</div><div class="">&nbsp; init(x: Int, y: Int) {</div><div class="">&nbsp; &nbsp; self.x = x</div><div class="">&nbsp; &nbsp; self.y = y</div><div class="">&nbsp; }</div><div class="">}</div><div class=""><br class=""></div><div class="">func move(var position: Position) {</div><div class="">&nbsp; position.x += 20</div><div class="">}</div><div class=""><br class=""></div><div class="">var p1 = Position(x: 10, y: 10)</div><div class="">move(p1)</div><div class=""><br class=""></div><div class="">print(p1.x) // prints 10</div></div><div class="">======<span style="line-height:1.5" class="">======</span><span style="line-height:1.5" class="">======</span><span style="line-height:1.5" class="">======</span><span style="line-height:1.5" class="">======</span><br class=""></div></div></div></div></div></blockquote></div><br class=""><div class="">Ah, OK, sure … but why is this a problem? You changed the declaration! Of course it behaves differently. Changing a declaration can transparently change behavior in any number of circumstances. The following code still compiles if you change “Int” to “UInt8,” but it crashes:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 10.5px; line-height: normal; font-family: Menlo;" class=""><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp;&nbsp;<span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">struct</span> Position {</div><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">var</span> x: <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">Int</span></div><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">var</span> y: <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">Int</span></div><p style="margin: 0px; font-size: 10.5px; line-height: normal; min-height: 12px;" class="">&nbsp;&nbsp; &nbsp; &nbsp;<br class="webkit-block-placeholder"></p><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">init</span>(x: <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">Int</span>, y: <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">Int</span>) {</div><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">x</span> = x</div><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">self</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">y</span> = y</div><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">func</span> move(<span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">var</span> position: <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">Position</span>) {</div><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp; &nbsp; position.<span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">x</span> += <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">200</span></div><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp; }</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">var</span> p1 = <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">Position</span>(x: <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">100</span>, y: <span style="font-variant-ligatures: no-common-ligatures; color: #323e7d" class="">100</span>)</div><div style="margin: 0px; font-size: 10.5px; line-height: normal;" class="">&nbsp; &nbsp; <span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">move</span>(<span style="font-variant-ligatures: no-common-ligatures; color: #587ea8" class="">p1</span>)</div><div style="margin: 0px; font-size: 10.5px; line-height: normal; min-height: 12px;" class=""><br class=""></div><div style="margin: 0px; font-size: 10.5px; line-height: normal; color: rgb(88, 126, 168);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">&nbsp; &nbsp; </span>print<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(</span>p1<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">.</span>x<span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">)</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class=""><br class=""></span></div></div></div><div class="">I could see this argument having some traction for protocol extensions, which can be attached to structs or classes with wildly different results. Protocols can limit themselves to classes only; can they limit themselves to structs as well? I don’t think so…. That could be a useful language change.</div><div class=""><br class=""></div><div class="">Cheers, P</div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>