<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="">On Dec 9, 2015, at 3:24 PM, J. Charles N. M. &lt;<a href="mailto:jcharles.nmbiada@gmail.com" class="">jcharles.nmbiada@gmail.com</a>&gt; wrote:<div><blockquote type="cite" class=""><div class=""><p dir="ltr" class="">I agree, the default case has no interest since _ is more "swift”.<br class=""></p></div></blockquote><div>I don’t think I expressed what I meant to. &nbsp;I’ll try again:</div><div><br class=""></div><div>1. The “case _” syntax already works and yet we have “default” anyways.</div><div>2. This is for a reason. &nbsp;It is more readable and familiar. &nbsp;</div><div>3. “default” is completely different than ++/— and&nbsp;c-style-for. Someone unfamiliar with it won’t look at it and be puzzled.</div><div>4. People use “default” all the time, making it dissimilar to ++, c-style-for, and fallthrough.</div><div>5. It is a redundancy in the language, and I agree that redundancy needs to be justified.</div><div><br class=""></div><div>In terms of justifying/defending keeping default, I’ll point out two arguments:</div><div><br class=""></div><div>1) We have had default and “case _” ever since Swift has been public. &nbsp;If you look at bodies of existing swift code, they almost unanimously use “default” instead of “case _”. &nbsp;This argues that default is more familiar and more widely used. &nbsp;It isn’t some legacy barnacle on the side that people generally ignore.</div><div><br class=""></div><div>2) This redundancy is precedented even in non-C-family languages like Haskell. &nbsp;Haskell’s pattern matching works similarly to Swifts (really, swifts works similarly to Haskell’s :-), and even Haskell uses “otherwise” [a] to serve the purposes of “default” in swift. &nbsp;While it is true that people could use “| True = 42” in Haskell, they almost always use "| otherwise = 42”. &nbsp;I don’t think this is an accident, this reflects on the readability difference and the intentionality difference. &nbsp;</div><div><br class=""></div><div>-Chris</div><div><br class=""></div><div>[a] Yes, I know that otherwise isn’t a keyword in Haskell, its a constant in the standard prelude.</div><br class=""><blockquote type="cite" class=""><div class=""><p dir="ltr" class="">
</p>
<div class="gmail_quote">Le&nbsp;10 déc. 2015 12:08 AM, "Jacob Bandes-Storch via swift-evolution" &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; a écrit&nbsp;:<br type="attribution" class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Sounds like the team/community has already shown that similarity with C isn't a priority that overrides clarity/simplicity in the language. Thus, +1<div class="gmail_extra">
<br class=""><div class="gmail_quote">On Wed, Dec 9, 2015 at 3:06 PM, Chris Lattner via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 9, 2015, at 3:01 PM, Mustafa Yusuf via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class=""><div class=""><div class=""><div style="font-size:10pt;font-family:Verdana,Arial,Helvetica,sans-serif" class=""><div class=""><br class=""></div><div class="">Hello all. In switch statements in swift if all the possible cases aren't covered we have to supply a default case.<br class=""></div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; let number = 10<br class=""></div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; switch number {<br class=""></div><div class="">&nbsp; &nbsp; case 10: print("yay")<br class=""></div><div class="">&nbsp; &nbsp; case 12: print("close")<br class=""></div><div class="">&nbsp; &nbsp; default: print("try again")</div><div class="">&nbsp; &nbsp; }<br class=""></div><div class=""><br class=""></div><div class="">My proposal is replace it with the "case _:".<br class=""></div><div class=""><br class=""></div><div style="font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">&nbsp; &nbsp; let number = 10<br class=""></div><div style="font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""></div><div style="font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">&nbsp; &nbsp; switch number {<br class=""></div><div style="font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">&nbsp; &nbsp; case 10: print("yay")<br class=""></div><div style="font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">&nbsp; &nbsp; case 12: print("close")<br class=""></div><div style="font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">&nbsp; &nbsp; case _: print("try again")<br class=""></div><div style="font-family:Verdana,Arial,Helvetica,sans-serif;font-size:13px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">&nbsp; &nbsp; }<br class=""></div><div class=""><br class=""></div><div class="">Since underscore in swift means "whatever I don't care" it suits here better than "default". Correct me If I am wrong but this is the only use for "default" keyword in swift I guess. So we can completely remove "default" keyword from the language.<br class=""></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=RC5Cq0zAxCHc1sM9Uy3-2BojrrUAw-2F96zH69NULNHPvCslvdAWVxFPatYqjoDiRb7Q3EgLqm6kAtN3Y8PJd96JZJBEX-2BGOB-2BO1RSgbeUddRPfnNY4iqt4BDptltY2IW1vBi9If3WzLLwBq7R8NbfcAKe20DVwEXtqhCJ6oNJCh0vv41VQgcPrysET-2FQbUs-2Fy7-2F3T3oOaH9LE8SrdRwboiyYlwtWHPLhTLqL-2FahDRrJyPs-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important" class="">
</div></div></blockquote><br class=""></div></div></div><div class="">FWIW, this is already supported.&nbsp; We *also* support default for clarity of code / because it reads better, and for similarly with the (extended) C family of languages.</div><div class=""><br class=""></div><div class="">-Chris</div><br class="">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=P-2BsYbBZHRBuLDBJaL4DIKDNfkkjpROowTyRAObV11qxNF6r-2FmW9Dz9-2FJokcxzd9sYsFLKPasd32mQiH1sgxyQlqTjrIyXoLwFTzjhcqZ7JkRwJWET3nVojOvFHT0HznZzcEECdKzDR9WgNVfXk8dGNrDYHsH4sVcKqSR22cmYD57sqiYRXqxn9LrSTqJKX0gvkxDU8atYeEgfWhWcTI9fn900Pvtbx6Dx0UOw1QTxO4-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important" class="">
</div>
<br class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=Jyrm1EQ6Ui8x50yXi4-2B72km8qdG5vHfi9xSHNwE4oko7Tm-2BepIaJjfEQBtD2-2BK2uZRAh1T4X4FobcDufsHkU4jb-2BuUpfhCrpoWqS2-2FjU3Ppqm0GZ-2F-2BaUkn7mmB3JnlW2Jes5BxfwlvYuTireYh9XiVJ8Ir75J5Oew9qbd4Onu8fpW6UW-2B7t-2F9M7xQKJKt47qwFPvihug45FrZRVrhXnWJd2KBqra-2FEsex-2FUDPD5qu6Q-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important" class="">
<br class="">_______________________________________________<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" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div>
</div></blockquote></div><br class=""></body></html>