Yes, but *this* proposal is precisely to make the label part of the name.<br><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 24, 2017 at 17:51 Christopher Kornher <<a href="mailto:ckornher@me.com">ckornher@me.com</a>> wrote:<br></div><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="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Jan 24, 2017, at 4:24 PM, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br class="m_-6413537681004000400Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div class="gmail_msg">I'm now confused who is arguing for what. Enums cases cannot have the same name. As far as I'm aware, this proposal does not seek to change that. Each case must still be unique. It only changes whether labels are regarded as part of the name or part of the associated type.</div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">Labels are currently neither part of the name nor part of the associated type. See my example (it runs in the playground in Xcode 8.2.1).</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Forgive any lack of precise terminology: Labels for enums with associated values are currently only used to create a "function signature" for constructing values for the enum. They are ignored in all other uses of the enum AFAIK.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">My proposal is a way to allow multiple cases with the same name without breaking existing code. It has the benefit of giving enums a richer meaning, in simple English:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Here is an example of a way to handle this currently and what it would become:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class="gmail_msg"><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">// Runs now</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">enum</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> MultipleTypes {</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">case</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> anInt( value: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="gmail_msg">Int</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> )</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">case</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> aString( value: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="gmail_msg">String</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> )</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">}</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0);min-height:15px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">enum</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> E {</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">case</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> a( a: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)" class="gmail_msg">MultipleTypes</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> )</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">}</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0);min-height:15px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> theCurrentWay = </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)" class="gmail_msg">E</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(49,89,93)" class="gmail_msg">a</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">( a: .</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(49,89,93)" class="gmail_msg">aString</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">( value: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(209,47,27)" class="gmail_msg">"str"</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">) )</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0);min-height:15px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></div><div style="margin:0px;line-height:normal;color:rgb(79,129,135)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">switch</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">theCurrentWay</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0)" class="gmail_msg"> {</span></div></div></div></div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class="gmail_msg"><div style="margin:0px;line-height:normal;color:rgb(0,0,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">case</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> .</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(49,89,93)" class="gmail_msg">a</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">( let x ) :</span></div></div></div></div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)" class="gmail_msg"><div style="margin:0px;line-height:normal;color:rgb(0,0,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">switch</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> x {</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">case</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> .</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(49,89,93)" class="gmail_msg">anInt</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">( let x ) :</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">break</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0);min-height:15px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><br class="m_-6413537681004000400webkit-block-placeholder gmail_msg"></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">case</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> .</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(49,89,93)" class="gmail_msg">aString</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">( let x ) :</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">break</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> }</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">}</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0);min-height:15px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></div><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">// Proposed:</span></div><div style="margin:0px;line-height:normal;color:rgb(0,0,0);min-height:15px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></div><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">/*</span></div><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">enum theNewWay {</span></div><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> case a( value: Int ) :</span></div><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> case a( value: String ) :</span></div><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">}</span></div><div style="margin:0px;line-height:normal;min-height:15px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></div><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">switch theCurrentWay {</span></div><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">case .a( let x: Int ) :</span></div><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> break</span></div><div style="margin:0px;line-height:normal;min-height:15px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></div><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">case .a( let x: String ) :</span></div><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> break</span></div><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">}</span></div><div style="margin:0px;line-height:normal" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">*/</span></div><div class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div></div></div></div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg">On Tue, Jan 24, 2017 at 17:16 Christopher Kornher via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:<br class="gmail_msg"></div><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"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Jan 24, 2017, at 4:02 PM, Daniel Duan <<a href="mailto:daniel@duan.org" class="gmail_msg" target="_blank">daniel@duan.org</a>> wrote:</div><br class="m_-6413537681004000400m_-6800127110907110955Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg"><br class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg">Daniel Duan</div>Sent from my iPhone</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg"><br class="gmail_msg">On Jan 24, 2017, at 2:53 PM, Daniel Duan via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:<br class="gmail_msg"><br class="gmail_msg"></div><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg">Daniel Duan</div>Sent from my iPhone</div><div class="gmail_msg"><br class="gmail_msg">On Jan 24, 2017, at 2:18 PM, Christopher Kornher via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:<br class="gmail_msg"><br class="gmail_msg"></div><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">I agree that this rule would be consistent with the handing of Swift function signatures, but my proposal is self-consistent and:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">1) It is more powerful, matching on the case name or not as required.</div><div class="gmail_msg">2) Is consistent with existing switches that ignore associated values</div><div class="gmail_msg">3) Is constant with ignored labels in other Swift constructs (proposed and in past versions of Swift, at least)</div><div class="gmail_msg">4) Avoids a possible API change for current enums. This is currently legal but would not be if the enum case “name” is the entire signature for constructing it:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">```</div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">enum</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span>E {</span></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> <span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">case</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span>a( a:<span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="gmail_msg">Int</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span>)</span></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> <span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">case</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span>b( a:<span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(112,61,170)" class="gmail_msg">Int</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span>)</span></div><div style="margin:0px;font-size:13px;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:13px;line-height:normal;font-family:Menlo;min-height:15px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">let</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span>anEmum =<span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)" class="gmail_msg">E</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(49,89,93)" class="gmail_msg">a</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">( a:<span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(39,42,216)" class="gmail_msg">4</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span>)</span></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo;min-height:15px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo;min-height:15px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo;color:rgb(186,45,162)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">switch</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)" class="gmail_msg">anEmum</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span>{</span></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">case</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span>.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(49,89,93)" class="gmail_msg">a</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">( let x ) :</span></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo;color:rgb(186,45,162)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> <span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">break</span></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">case</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span>.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(49,89,93)" class="gmail_msg">b</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">( let x ) :</span></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo;color:rgb(186,45,162)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> <span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">break</span></div><div style="margin:0px;font-size:13px;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:13px;line-height:normal;font-family:Menlo;min-height:15px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo;color:rgb(186,45,162)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">switch</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(79,129,135)" class="gmail_msg">anEmum</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span>{</span></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">case</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span>.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(49,89,93)" class="gmail_msg">a</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">( let y ) :</span></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo;color:rgb(186,45,162)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> <span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">break</span></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo;min-height:15px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><br class="gmail_msg m_-6413537681004000400m_-6800127110907110955webkit-block-placeholder"></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)" class="gmail_msg">case</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span>.</span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(49,89,93)" class="gmail_msg">b</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">( let y ) :</span></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo;color:rgb(186,45,162)" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> <span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-converted-space"> </span></span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">break</span></div><div style="margin:0px;font-size:13px;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:13px;line-height:normal;font-family:Menlo" class="gmail_msg"><span class="gmail_msg">```</span></div><div class="gmail_msg">So is this proposal worth creating a breaking change? I don’t think so. it would be possible to ignore the associated parameter name, but not the type, but that would further confuse case matching, I believe.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I personally don’t see much purpose in having two enum cases with the same name if they are always treated as distinct and there is no way to reason on the case name.</div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Would you say the same for functions? Our opinions differ in what constitute a "name". In Swift, function names include parameters. Each enum case declares a function that creates a enum value. That's why it's *more* consistent for enum to have a similar definition of "name".</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">As for pattern matching, number of patterns the number of cases being matched have a many-to-one relationships. This is true in Swift and many </div><br class="gmail_msg"></div></blockquote><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg"><br class="gmail_msg"></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg">(Ah, accidentally sent it on my iPhone. My apologies.)</div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg"><br class="gmail_msg"></div><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg">… other languages. What you are proposing complicates the rules by making this untrue. We'd have to special-case this feature in our pattern matching algorithm.</div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">I am not proposing a breaking change. I believe that it is the best way to handle “overloading” enum names without breaking existing code. I don’t believe that this proposal changes any existing logic or rules.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg">The use of the terms "name” and "signature" is well established in many languages. e.g.: <a href="https://en.wikipedia.org/wiki/Type_signature" class="gmail_msg" target="_blank">https://en.wikipedia.org/wiki/Type_signature</a> I am trying to use the terms in this context.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Sharing a function name (with different signatures) is an aid to understanding the purpose of functions and is part of many languages. I do not believe that extending the concept to enums is worth the cost, especially since it will break existing Swift code.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">You are proposing a source breaking change and I do not agree that is is an improvement. What is the benefit of this change?</div><br class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"></div></blockquote></div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg"><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">If they are always distinct, then requiring different names eliminates unnecessary cognitive load. There is a good reason for functions to have the same “name” and different signatures, and there are precedents in many languages. </div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">You may disagree, but I believe that enums exist to support reasoning on distinct cases and that muddying that by treating the associated value as part of the “signature" increases the language “surface area” while adding no tangible benefit.</div><div class="gmail_msg"><br class="gmail_msg"></div><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Jan 24, 2017, at 2:23 PM, Matthew Johnson via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br class="m_-6413537681004000400m_-6800127110907110955Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><br class="m_-6413537681004000400m_-6800127110907110955Apple-interchange-newline gmail_msg">On Jan 24, 2017, at 3:10 PM, Christopher Kornher via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br class="m_-6413537681004000400m_-6800127110907110955Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg">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. </div></div></div></blockquote><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">It sounds like you are missing something. The `bar(a:)` and `bar(b:)` are the full case names. These are *not* the same case. 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. The programmer is required to spell out the full name of the case they wish to match.</div><div class="gmail_msg"><br class="gmail_msg"></div><br class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">It would still be possible to match on the different types of bar when needed:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">```</div><div class="gmail_msg">enum Foo {<br class="gmail_msg"> case bar(a: Int)<br class="gmail_msg"> case bar(b: String)</div><div class="gmail_msg"> case notAbar<br class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">}</div></div></div></div></div><div class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div></div></div></div></div><br class="m_-6413537681004000400m_-6800127110907110955Apple-interchange-newline gmail_msg"><div class="gmail_msg"> switch aFoo {</div><div class="gmail_msg"> case .bar( let a: Int) : // matches Ints only </div><div class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-tab-span" style="white-space:pre-wrap">        </span>...</div><div class="gmail_msg"><br class="gmail_msg"> case .bar( let b: String) : // matches Strings only<br class="gmail_msg"> ...<br class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">}</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg">switch aFoo {</div><div class="gmail_msg"> case .bar : // Matches both cases and that is a good thing</div><div class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-tab-span" style="white-space:pre-wrap">        </span>…</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"> case notAbar:</div><div class="gmail_msg"><span class="gmail_msg m_-6413537681004000400m_-6800127110907110955Apple-tab-span" style="white-space:pre-wrap">        </span>….</div><div class="gmail_msg">}<br class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div></div></div></div></div></div><div class="gmail_msg">```</div><div class="gmail_msg"><br class="gmail_msg"></div></div></div></div></div><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Jan 24, 2017, at 5:27 AM, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br class="m_-6413537681004000400m_-6800127110907110955Apple-interchange-newline gmail_msg"><div class="gmail_msg">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="gmail_msg"><br class="gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div class="gmail_msg">On Tue, Jan 24, 2017 at 01:13 David Hart via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div 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 <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> 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 class="gmail_msg" style="margin:0px 0px 0px 40px;border:none;padding:0px"><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) -> () = 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 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"> case bar(a: Int)</div><div class="gmail_msg"> 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"> case .bar: // matches both cases</div><div class="gmail_msg"> 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="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></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" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></div></blockquote></div><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class="gmail_msg">_______________________________________________</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg"><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important" class="gmail_msg">swift-evolution mailing list</span><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg"><a href="mailto:swift-evolution@swift.org" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class="gmail_msg"></div></blockquote><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><span class="gmail_msg">_______________________________________________</span><br class="gmail_msg"><span class="gmail_msg">swift-evolution mailing list</span><br class="gmail_msg"><span class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a></span><br class="gmail_msg"><span 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></span><br class="gmail_msg"></div></blockquote></div></blockquote><blockquote type="cite" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="gmail_msg"><div class="gmail_msg"><span class="gmail_msg">_______________________________________________</span><br class="gmail_msg"><span class="gmail_msg">swift-evolution mailing list</span><br class="gmail_msg"><span class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a></span><br class="gmail_msg"><span 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></span></div></blockquote></div></blockquote></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></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" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></div></blockquote></div></div></blockquote></div>