<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 Jan 24, 2017, at 3:10 PM, Christopher Kornher 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=""><div class="">Your example is only has only one case, which is not typical. Perhaps I am missing something, but the only reason that I can imagine for having a case with multiple ways to “construct” it is to have all variants of the case to match. If you don’t want them to match, use a different case name.&nbsp;</div></div></div></blockquote><div><br class=""></div><div>It sounds like you are missing something. &nbsp;The `bar(a:)` and `bar(b:)` are the full case names. &nbsp;These are *not* the same case. &nbsp;The `bar` shorthand is allowed when there is no ambiguity, however for an enum with both `bar(a:)` and `bar(b:)` there *is* ambiguity and therefore the `bar` shorthand is not allowed. &nbsp;The programmer is required to spell out the full name of the case they wish to match.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">It would still be possible to match on the different types of bar when needed:</div><div class=""><br class=""></div><div class="">```</div><div class="">enum Foo {<br class="">&nbsp; &nbsp; case bar(a: Int)<br class="">&nbsp; &nbsp; case bar(b: String)</div><div class="">&nbsp; &nbsp; case notAbar<br class=""><div class="gmail_quote"><div dir="auto" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">}</div></div></div></div></div><div class=""><div class="gmail_quote"><div dir="auto" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><br class=""></div></div></div></div></div><br class="Apple-interchange-newline"><div class="">&nbsp;switch aFoo {</div><div class="">&nbsp; &nbsp; case .bar( let a: Int) : // matches Ints only&nbsp;</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>...</div><div class=""><br class="">&nbsp; &nbsp; case .bar( let b: String) : //&nbsp;matches Strings only<br class="">&nbsp; &nbsp; &nbsp; &nbsp;...<br class=""><div class="gmail_quote"><div dir="auto" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">}</div><div class="gmail_msg"><br class=""></div><div class="gmail_msg"><div class="">switch aFoo {</div><div class="">&nbsp; &nbsp; case .bar : &nbsp;// Matches both &nbsp;cases and that is a good thing</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>…</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; case notAbar:</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>….</div><div class="">}<br class=""><div class="gmail_quote"><div dir="auto" class="gmail_msg"><div class="gmail_msg"><div class=""><br class=""></div></div></div></div></div></div><div class="gmail_msg">```</div><div class="gmail_msg"><br class=""></div></div></div></div></div><div class=""><blockquote type="cite" class=""><div class="">On Jan 24, 2017, at 5:27 AM, Xiaodi Wu 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="">I would imagine it would be logical to have it work just like it does now with functions. If case bar is distinct, then that should still work, but if bar is "overloaded," then case bar should be invalid for ambiguity. Seems fine to me, shouldn't break any existing code and therefore we don't lose anything.<br class=""><br class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Tue, Jan 24, 2017 at 01:13 David Hart via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg">On 24 Jan 2017, at 00:52, Joe Groff via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="gmail_msg"><br class="gmail_msg"></div><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">We're not terribly principled about this right now with non-pattern declaration references. You can still reference an unapplied function by its base name alone without its labels, if it's unambiguous:</div><div class="gmail_msg"><br class="gmail_msg"></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px" class="gmail_msg"><div class="gmail_msg">func foo(x: Int, y: Int) {}</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">let foo_x_y: (Int, Int) -&gt; () = foo</div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">so it'd be consistent to continue to allow the same in pattern references.</div></div></blockquote><br class="gmail_msg"></div></div><div dir="auto" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">WRT ambiguity, do we loose the ability to pattern match on the naked case name when two cases share the same base name?</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">enum Foo {</div><div class="gmail_msg">&nbsp; &nbsp; case bar(a: Int)</div><div class="gmail_msg">&nbsp; &nbsp; case bar(b: String)</div><div class="gmail_msg">}</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">switch aFoo {</div><div class="gmail_msg">&nbsp; &nbsp; case .bar: // matches both cases</div><div class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; break</div><div class="gmail_msg">}</div></div></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=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></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>