<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=""><div class="">As the original poster of this thread, I wanted to re-state the original question:</div><div class=""><br class=""></div><div class="">Should enums REQUIRE parameter names?</div><div class=""><br class=""></div><div class="">Pro:<span class="Apple-tab-span" style="white-space:pre">                </span>The syntax would more closely match that for functions, which requires names for all parameters (unless you say “_”) vs. the current syntax that is sort of C-like.</div><div class="">Con:<span class="Apple-tab-span" style="white-space:pre">        </span>More verbose</div><div class=""><br class=""></div><div class="">With this suggestion, your declaration of a variable that uses an enum would resemble calling a function. e.g.:</div><div class=""><br class=""></div><div class="">var myTeam = Team.football (name: “Redskins”, city: “Washington, DC”, quarterback: “Kirk Cousins”)</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 30, 2016, at 5:14 AM, Adrian Zubarev 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=""><div class="bloop_markdown" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);"><p style="margin: 15px 0px; -webkit-margin-before: 0px;" class="">Fair point, the more and more I’m thinking about default values, the more I’m convinced here.</p><p style="margin: 15px 0px;" class="">And yes, as I mentioned before, default value would solve the problem in my API. I’m thinking of adapting the pitched idea so I almost get the right behaviour for free when Swift 4 drops.</p><div style="margin: 15px 0px;" class=""><br class="webkit-block-placeholder"></div></div><div class="bloop_original_html" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);"><div id="bloop_customfont" style="font-family: Helvetica, Arial; font-size: 13px; margin: 0px;" class=""><br class=""></div><br class=""><div id="bloop_sign_1480500747365548032" class="bloop_sign"><div style="font-family: helvetica, arial; font-size: 13px;" class="">-- <br class="">Adrian Zubarev<br class="">Sent with Airmail</div></div><br class=""><p class="airmail_on" style="margin: 15px 0px;">Am 30. November 2016 um 04:32:17, Karl (<a href="mailto:razielim@gmail.com" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;" class="">razielim@gmail.com</a>) schrieb:</p><blockquote type="cite" class="clean_bq" style="margin: 15px 0px;"><span style="margin-top: 0px; margin-bottom: 0px;" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class="" style="margin: 15px 0px;"><div class="" style="margin-top: 0px;">On 29 Nov 2016, at 18:41, Tony Allevato via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="" style="color: rgb(65, 131, 196); background-color: inherit; text-decoration: none;">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class="" style="margin-bottom: 0px;"><div dir="ltr" class="">Default values and overloaded cases don't (and in fact, shouldn't) be conflated.<div class=""><br class=""></div><div class="">I support default values for associated values but I'm not yet ready to say I'm in favor of overloaded cases. There's no ambiguity because your Value.number example can't exist without overloads, and default values don't create parameter lists that could mismatch like that (there's still only one case, and it has all of the associated values regardless of how many you specify at the time you create it).</div><div class=""><br class=""></div><div class="">Small self-contained examples like Value are nice, but entirely hypothetical and a bit contrived. "Maybe the design of the API does not want something" is difficult to convince me—I'd prefer to see a significant real world situation where it's vital to have two cases with the same name with differently typed payloads, which can't be expressed in a different way. For example, in your Javascript example, I think the optionality of that Document would be far better expressed as an Optional<Document> with a default value of nil than creating an overload, and that solution introduces far less complexity to the language than would introducing arbitrary overloads.</div></div></div></blockquote><br class=""></div><div class="">Yeah, we shouldn’t confuse these issues. Default values for enum payloads are something I also really want (in Swift 4 phase 2). Here’s my use-case:</div><div class=""><br class=""></div><div class=""><pre class="" style="margin: 0px; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; background-color: rgb(247, 247, 247); color: rgb(51, 51, 51); border: 1px solid rgb(204, 204, 204); overflow: auto; padding: 16px; word-break: normal; word-wrap: normal; box-sizing: border-box; line-height: 1.45;"><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">public</span> <span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">enum</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">ReadError</span> : <span class="pl-e" style="box-sizing: border-box; color: rgb(121, 93, 163);"><span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">Error</span> </span>{
<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">case</span> <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">otherError</span>(<span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);"><span class="pl-smi" style="box-sizing: border-box; color: rgb(51, 51, 51);">description</span></span>: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">String</span>, <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);"><span class="pl-smi" style="box-sizing: border-box; color: rgb(51, 51, 51);">location</span></span>: <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">StaticString</span><span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">?</span> = #function) <span class="pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);">// <- currently an error, tuples can't have default values</span>
}</pre><div class=""><br class=""></div></div><div class="">And yes, you can use #function as a default value:</div><div class=""><br class=""></div><blockquote class="" style="margin: 0px 0px 0px 40px; border: none; padding: 0px;"><div class="" style="margin-top: 0px;"><font face="Courier" class="">func doIt(_ str: String = #function) {</font></div><div class=""><font face="Courier" class=""> print("Called from \(str)") </font></div><div class=""><font face="Courier" class="">}</font></div><div class=""><font face="Courier" class="">func myFunc() { doIt() }</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class="">doIt() // Prints “Called from __lldb_expr_1” in REPL</font></div><div class=""><font face="Courier" class="">myFunc() // Prints “Called from myFunc()”</font></div><div class="" style="margin-bottom: 0px;"><font face="Courier" class=""><br class=""></font></div></blockquote><div class=""><br class=""></div>I think that’s a more valuable use-case than overloaded values; so if they’re incompatible and we have to choose one, I’d go for default values.<div class=""><br class=""></div><div class="">- Karl</div></div></div></span></blockquote></div><div class="bloop_markdown" style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);"><div style="margin: 15px 0px; -webkit-margin-before: 0px;" class=""><br class="webkit-block-placeholder"></div></div><span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254); float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);" class=""><span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254); float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);" class=""><span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254); float: none; display: inline !important;" class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);" class=""><span style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254); float: none; display: inline !important;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br style="font-family: Helvetica, Arial; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(254, 254, 254);" class=""></div></blockquote></div><br class=""></body></html>