<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 Feb 22, 2017, at 8:25 PM, Derrick Ho via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">Did you know you can use a static variable as a default parameter?<br class=""><br class="">class poncho {<br class=""> static var color= "yellow"<br class=""><br class=""> func foo(color: String = poncho.color){}<br class="">}<br class=""><br class="">I think instance members should not be allowed as default members though. It may lead to unexpected behavior.<br class=""></div></blockquote><div><br class=""></div>Could you explain or give an example of how the behavior would be unexpected?</div><div><br class=""><blockquote type="cite" class=""><div class=""><div class="gmail_quote"><div dir="ltr" class="">On Wed, Feb 22, 2017 at 11:06 PM T.J. Usiyan via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="gmail_msg">+1 if this doesn't have terrible implications. <div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">The downside to making it IUO or Optional is that that changes the type signature of `index(i:offsetBy:)` for no reason other than a default value. If you decide to change to or away from providing a default value it probably shouldn't change the type accepted in that spot. </div></div><div class="gmail_extra gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg">On Wed, Feb 22, 2017 at 7:32 PM, Ben Cohen via swift-evolution <span dir="ltr" class="gmail_msg"><<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br class="gmail_msg"><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="m_5977326494558568233h5 gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Feb 22, 2017, at 10:42 AM, Nate Cook via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br class="gmail_msg m_5977326494558568233m_1074355987617192004Apple-interchange-newline"><div class="gmail_msg"><div style="word-wrap:break-word" class="gmail_msg">Oops, left out that there's this horrifying way of writing it right now:<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg"><font face="Menlo" class="gmail_msg">extension Collection {</font></div><div class="gmail_msg"><font face="Menlo" class="gmail_msg"> func index(_ i: Index! = nil, offsetBy n: IndexDistance) -> Index {</font></div><div class="gmail_msg"><font face="Menlo" class="gmail_msg"> let i = i ?? startIndex</font></div><div class="gmail_msg"><font face="Menlo" class="gmail_msg"> // ...</font></div><div class="gmail_msg"><font face="Menlo" class="gmail_msg"> }</font></div><div class="gmail_msg"><font face="Menlo" class="gmail_msg">}</font></div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Nobody wants that.</div><div class="gmail_msg"><br class="gmail_msg"></div></div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></div></div><div class="gmail_msg">Oh I don’t think it’s all that bad! It also doesn’t need to be an IUO, since you’re unwrapping it immediately into another variable no matter what.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">This also gives you the flexibility to write this:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(52,149,175)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff" class="gmail_msg">extension</span><span style="font-variant-ligatures: no-common-ligatures;" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">Collection</span><span style="font-variant-ligatures: no-common-ligatures;" class="gmail_msg"> {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff" class="gmail_msg">func</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> index(</span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff" class="gmail_msg">_</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> i: Index? = </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff" class="gmail_msg">nil</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">, offsetBy n: IndexDistance) -> Index {</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#0433ff" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> i = i ?? (n </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af" class="gmail_msg"><</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> 0 ? </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af" class="gmail_msg">endIndex</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> : </span><span style="font-variant-ligatures:no-common-ligatures;color:#3495af" class="gmail_msg">startIndex</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">)</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#008f00" class="gmail_msg">// ...</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> }</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">}</span></div><div class="gmail_msg"><br class="gmail_msg"></div></div><span class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">_______________________________________________<br class="gmail_msg">swift-evolution mailing list<br class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></div></blockquote></span></div><br class="gmail_msg"></div><br class="gmail_msg">_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
<br class="gmail_msg"></blockquote></div><br class="gmail_msg"></div>
_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>