<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=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""><br class=""></div><div class=""><br class="">On Mar 11, 2017, at 12:20 PM, David Sweeris via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Mar 11, 2017, at 12:57 AM, Jean-Daniel 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=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">-1<div class=""><br class=""></div><div class="">It would be inconsistent to allow it for deterministic literals (String) and not for non deterministic literal (int which can be either a Int, Uint, Float, …)</div></div></div></blockquote><div class=""><br class=""></div>If I’m not mistaken, even with `bar = “baz”`, `String` is merely the <i class="">default</i> inferred type. It <i class="">could</i> be anything that conforms to `ExpressibleByStringLiteral`, right? In that regard, this is kinda just a way to make a function implicitly generic:</div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;foo(bar =&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(209, 47, 27);">"baz"</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) {…</span>}</div></div></div></blockquote><div class=""><div class=""><div class="" style="margin: 0px; line-height: normal;">becomes:</div></div></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div class=""><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" style="font-size: 11px;" class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="" style="color: rgb(186, 45, 162);">func</span>&nbsp;foo&lt;T: ExpressibleByStringLiteral&gt;(bar: T =&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(209, 47, 27);">"baz"</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) {…</span>}</font></div></div></div></div></blockquote><div class=""><div class=""><div class="" style="margin: 0px; line-height: normal;"><div class=""><br class=""></div></div></div></div></div></blockquote><div class=""><br class=""></div><div class="">As I understood it, omitting the type would work identically to `let` declarations. A string literal without a type defaults to `String`. Treating it as a generic function is a bad idea IMO.</div><div class=""><br class=""></div><div class="">I don't think this sugar is worth any amount of added complexity. Most function arguments will have not have default values and this have to continue to declare the type, so this would only be more concise in very few cases. I'd prefer the consistency of always having to explicitly declare the argument type at a function boundary.</div><div class=""><br class=""></div><div class="">To call a function, you need to know what type to pass in. This becomes more difficult when not make explicit, particularly when a more complicated expression is used as a default. -1</div><br class=""><blockquote type="cite" class=""><div class=""><div class=""><div class=""><div class="" style="margin: 0px; line-height: normal;"><div class="">Is there anything we can do with a variable, if all we know of it is that it conforms to `ExpressibleByStringLiteral`? I can’t think of anything… If we had a way to get back the literal string which the variable was initialized with, we could initialize other values with that, but the protocol doesn’t require us to store it. Come to think of it, is there even a way to store a literal value in its “untyped” form? You can declare a variable to of type `IntegerLiteralType`, but the type system then treats it as an `Int`.</div><div class=""><br class=""></div><div class="">So while it looks nice (to me, anyway) I’m not sure you could actually do anything with it. Or am I looking at this wrong?</div><div class=""><br class=""></div><div class="">- Dave Sweeris</div></div></div></div></div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></div></body></html>