<div dir="ltr">I would be alright with this change. The slight inconvenience, even in teaching, would be worth it, in my opinion. It is easier for developers to reason about the types intended when they are made explicit.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Apr 9, 2017 at 6:01 PM, Jon Shier via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span class="m_8962071201875937301Apple-tab-span" style="white-space:pre-wrap">        </span>I generally dislike any language change desired because it makes the compiler implementation easier. We saw a few such changes for Swift 3 and all of them were net negatives for the actual users of the language (to a minor extent for most, to be fair). I would hope that, as the compiler matures, these types of inference performance issues will become less of a problem. Removing a rather nice language feature, especially one that plays such a big role in the “feel” of the language, for short term gain seems rather shortsighted to me.<div><br></div><div><br></div><div><br></div><div>Jon Shier<div><div class="h5"><br><div><br></div><div><br><div><blockquote type="cite"><div>On Apr 9, 2017, at 11:23 AM, Lucas Neiva via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br class="m_8962071201875937301Apple-interchange-newline"><div><div 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 <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br><br></div><blockquote type="cite"><div><div><blockquote type="cite"><div>On Apr 7, 2017, at 12:21 AM, Daniel Duan via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br class="m_8962071201875937301Apple-interchange-newline"><div><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;float:none;display:inline!important">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"></div></blockquote></div><div><br></div><div>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><br></div><div><span class="m_8962071201875937301Apple-tab-span" style="white-space:pre-wrap">        </span>struct Point {</div><div><span class="m_8962071201875937301Apple-tab-span" style="white-space:pre-wrap">                </span>var x = 0.0</div><div><span class="m_8962071201875937301Apple-tab-span" style="white-space:pre-wrap">                </span>var y = 0.0</div><div><span class="m_8962071201875937301Apple-tab-span" style="white-space:pre-wrap">        </span>}</div><div><br></div><div>Or:</div><div><br></div><div><span class="m_8962071201875937301Apple-tab-span" style="white-space:pre-wrap">        </span>struct Person {</div><div><span class="m_8962071201875937301Apple-tab-span" style="white-space:pre-wrap">                </span>var name = ""</div><div><span class="m_8962071201875937301Apple-tab-span" style="white-space:pre-wrap">                </span>var age = 18</div><div><span class="m_8962071201875937301Apple-tab-span" style="white-space:pre-wrap">        </span>}</div><div><br></div><div>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><br></div><div>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><div>
<span class="m_8962071201875937301Apple-style-span" style="border-collapse:separate;font-family:Helvetica;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;border-spacing:0px"><div><div style="font-size:12px">-- </div><div style="font-size:12px">Brent Royal-Gordon</div><div style="font-size:12px">Architechies</div></div></span>
</div>
<br></div></blockquote><blockquote type="cite"><div><span>______________________________<wbr>_________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a></span><br></div></blockquote></div>______________________________<wbr>_________________<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" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br></div></blockquote></div><br></div></div></div></div></div><br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br></div>