<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>If inference only works in simple cases, I think it would seem like it works unpredictability to anyone unfamiliar with the implementation details.</div><div><br></div><div>I image the question of "why do I have to declare a type here, but not in this case?" coming up.</div><div><br></div><div>Declaring types is one of the first things you have to learn anyway. Just declaring a function already requires some understanding of types. Properties are not much different IMO.</div><div><br>On 8 Apr 2017, at 08:34, Brent Royal-Gordon via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><div><blockquote type="cite" class=""><div class="">On Apr 7, 2017, at 12:21 AM, Daniel Duan via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">The cons for doing this are obvious too: the inference makes the language feels more friendly and is, undoubtedly, a beloved feature for many. This would be a source breaking change.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote></div><div class=""><br class=""></div><div class="">Beyond just being more friendly, I think it could be considered a teaching issue. A great way to introduce beginners to custom types would be something like:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>struct Point {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>var x = 0.0</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>var y = 0.0</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div class=""><br class=""></div><div class="">Or:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>struct Person {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>var name = ""</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>var age = 18</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div class=""><br class=""></div><div class="">If you have to explicitly specify types for the properties, that's another thing you need to introduce to people before you can do this.</div><div class=""><br class=""></div><div class="">On the other hand, a very limited form of inference might be fine here. Imagine if we did a sort of limited, single-pass, top-down inference which only understood a few things (literals, tuple syntax, initializer calls), stopped once it had seen enough to infer a complete type, and rejected an expression if it encountered something it didn't understand before finishing. That would probably cover most simple cases, and it would probably only allow expressions whose types were obvious enough that we could use it for arguments, too. (But of course it would mean more code in the compiler, so it might not be worth it.)</div><br class=""><div class="">
<span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;  "><div class=""><div style="font-size: 12px; " class="">--&nbsp;</div><div style="font-size: 12px; " class="">Brent Royal-Gordon</div><div style="font-size: 12px; " class="">Architechies</div></div></span>

</div>
<br class=""></div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></body></html>