<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="">Am 14.01.2016 um 22:37 schrieb Charles Constant via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>>:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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;" class="">I mean, if we can get it across that we're taking a<span class="Apple-converted-space"> </span><b class="">very common task</b>, and making it<span class="Apple-converted-space"> </span><b class="">less verbose</b><span class="Apple-converted-space"> </span>AND<span class="Apple-converted-space"> </span><b class="">easier to read</b>. To me it seems like a massive win.<br class=""></div></div></blockquote><div><br class=""></div>And with chaining or the possibility to ask isDefinedAt() (see my other mail) we also get more expressivity!</div><div><br class=""></div><div>-Thorsten</div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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;" class=""><div class=""><br class=""></div><div class="">> <span style="font-size: 13px;" class="">(I guess today actually since it is now </span><span class="" tabindex="0" style="font-size: 13px;"><span class="">4:30am</span></span><span style="font-size: 13px;" class="">).</span></div><div class=""><br class=""></div><div class="">Ha, typical programmer. Get some sleep!</div><div class=""><span style="font-size: 13px;" class=""><br class=""></span></div></div><div class="gmail_extra" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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;"><br class=""><div class="gmail_quote">On Thu, Jan 14, 2016 at 1:34 PM, Craig Cruden<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:ccruden@novafore.com" target="_blank" class="">ccruden@novafore.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" 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 style="word-wrap: break-word;" class="">Thanks, I think I understand now. I will sleep on it and then come up with a new draft of that section tomorrow (I guess today actually since it is now 4:30am).<div class=""><div class="h5"><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 2016-01-15, at 4:29:12, Charles Constant <<a href="mailto:charles@charlesism.com" target="_blank" class="">charles@charlesism.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">That was my attempt, maybe a poor one, at expressing what we're trying to do. I guess another way to express it is that we're "mapping" but only mapping one possible value.<div class=""><div class=""><br class=""></div><div class="">Maybe "domain" isn't the best choice of words, but fwiw I meant, say for the "ternary expression":</div><div class=""><div class=""><br class=""></div><div class="">let result = boo ? "it worked" : "it failed"</div></div><div class=""><br class=""></div><div class=""><div class="">I was thinking that what we're doing is kind of this:</div></div><div class=""><br class=""></div><div class="">Domain A is "Boolean Values", which can be: "true" or "false"</div><div class="">Domain B is "Status Strings", which can be "It worked" or "it failed"</div><div class=""><br class=""></div><div class="">So our ternary maps the states of our bool to the states of our strings, and uses the value as a key. Does that make sense? Well, maybe not :)</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Jan 14, 2016 at 1:21 PM, Craig Cruden<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:ccruden@novafore.com" target="_blank" class="">ccruden@novafore.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" 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 style="word-wrap: break-word;" class="">Thanks, <div class=""><br class=""></div><div class=""><span class=""><blockquote type="cite" class=""><div dir="ltr" class=""><div class="">- the need to use a value from one domain, as a "key" to another is very common. The ternary is a special case of this, and for all it's flaws, it's a very popular expression in multiple languages </div></div></blockquote><div class=""><br class=""></div></span><div class="">This one I am not quite sure what you are saying with this one - can you expand it a bit so I understand the key selling point? The rest of the points I understand.</div><div class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 2016-01-15, at 4:16:56, Charles Constant <<a href="mailto:charles@charlesism.com" target="_blank" class="">charles@charlesism.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class="">Hi Craig,<div class=""><br class=""></div><div class="">Well done, what you wrote looks pretty good to me. I had no trouble understanding the proposal. It's a good length, too - I think the shorter we can make it, the more appealing it is. </div><div class=""><br class=""></div><div class="">The only section that I think needs improvement is "Motivation." I think we could sell it better. I know when I've read some of the other proposals, I do it in fairly cursory way.</div><div class="">"Motivation" could be clearer for those of our peers who haven't followed the thread. <br class=""></div><div class=""><br class=""></div><div class="">The motivation, from my point of view:</div><div class="">- the need to use a value from one domain, as a "key" to another is very common. The ternary is a special case of this, and for all it's flaws, it's a very popular expression in multiple languages </div><div class="">- using the existing "switch" to do this is bloated (more so in Swift because you have to declare the variable before the switch statement)</div><div class="">- using the existing "switch" to do this is less safe, because unrelated code can be inserted in the case statements<br class=""></div><div class="">- current alternatives to "switch" aren't good (e.g.: using a Dict has quirks that add the cognitive load)</div><div class="">- this new "map" method can make code less verbose, easier to read, and safer</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Jan 14, 2016 at 11:23 AM, Craig Cruden<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:ccruden@novafore.com" target="_blank" class="">ccruden@novafore.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><blockquote class="gmail_quote" 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 style="word-wrap: break-word;" class=""><div class="">Paul, </div><div class=""><br class=""></div>I tried to put my understanding on the latest proposal option into a draft on github (instead of my usual BitBucket repo). <div class=""><br class=""></div><div class="">Take a look at it and see if there is anything useable.</div><div class=""><br class=""></div><div class=""><a href="https://github.com/cacruden/swift-evolution/blob/master/proposals/0000-Pattern-Matching-Partial-Function.md" target="_blank" class="">https://github.com/cacruden/swift-evolution/blob/master/proposals/0000-Pattern-Matching-Partial-Function.md</a></div><span class=""><font color="#888888" class=""><div class=""><br class=""></div><div class="">Craig</div></font></span><div class=""><div class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 2016-01-11, at 14:17:09, Craig Cruden <<a href="mailto:ccruden@novafore.com" target="_blank" class="">ccruden@novafore.com</a>> wrote:</div><br class=""><div class=""><div style="word-wrap: break-word;" class="">Ignore the last comment - tired and mistaken. :p<div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 2016-01-11, at 14:16:01, Craig Cruden <<a href="mailto:ccruden@novafore.com" target="_blank" class="">ccruden@novafore.com</a>> wrote:</div><br class=""><div class=""><div style="word-wrap: break-word;" class="">I just realized “cases” probably is not needed - if it see’s a comma after case but before “:” then it is the concise form. <div class=""><br class=""></div><div class="">If the switch / case can do that , the partial function case should be able to do the same thing.</div><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 2016-01-11, at 13:23:19, Craig Cruden <<a href="mailto:ccruden@novafore.com" target="_blank" class="">ccruden@novafore.com</a>> wrote:</div><br class=""><div class=""><div style="word-wrap: break-word;" class=""><div class="">I have thought about it a bit more and I think this would cover all the cases that interest me (in addition to others needs for a little more conciseness on the most simple case). </div><div class=""><br class=""></div><div class="">I also think we need to be clear that the “case” (or cases) and “default” are is really just a partial function which in it’s entirety is really just a complete function for used wherever a complete function (exhaustive) can be passed (e.g. reduce, filter, etc.) - otherwise they might get confused on why we are adding it to “map”. </div><div class=""><br class=""></div><div class="">The optional where clause should also be part of the case clause as part of the proposal. </div><div class=""><br class=""></div><div class="">There would be no need for statement based “fallthrough”.</div><div class=""><br class=""></div><div class="">You mentioned your proposal…. have you drafted a formal proposal draft?</div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 2016-01-10, at 12:41:03, Paul Ossenbruggen via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</div><br class=""><div class="">I agree that it would be really useful to keep things concise. I am going to suggest again an idea I had in the past, it is also in my proposal, which might work well for this problem. This might address the verbosity of the “case” and at the same time make it obvious we are dealing with a switch expression. So both would be valid: <div class=""><br class=""></div><div class=""><div class=""><div dir="ltr" class=""><div style="word-wrap: break-word;" class=""><div dir="ltr" class=""><div style="word-wrap: break-word;" class=""><div dir="ltr" class=""><div style="font-size: 13px; margin: 0px; line-height: normal; font-family: Arial;" class=""><b class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-weight: normal;" class=""><div style="word-wrap: break-word;" class=""><div dir="ltr" class=""><div style="word-wrap: break-word;" class=""><div dir="ltr" class=""><b style="font-family: Arial; font-size: 13px;" class=""><b class=""><span style="color: rgb(96, 96, 96); white-space: pre-wrap;" class="">        </span><font color="#006d8f" class="">let</font></b><b style="color: rgb(96, 96, 96);" class=""> num = color.</b><font color="#008cb4" class="">map </font>{</b></div></div></div></div></div></b></div></div></div></div></div></div></div></div></div></blockquote><blockquote type="cite" class=""><b style="font-family: Arial; font-size: 13px;" class=""><b style="color: rgb(96, 96, 96);" class=""><span style="white-space: pre-wrap;" class="">        </span></b><b class=""><span style="white-space: pre-wrap;" class=""><font color="#606060" class="">        </font><font color="#006d8f" class="">cases</font><font color="#606060" class=""> </font></span></b><b class=""><font color="#4f7a28" class="">.Red:</font></b><b style="color: rgb(227, 36, 0);" class=""> </b><b style="color: rgb(96, 96, 96);" class="">100,</b><b style="color: rgb(96, 96, 96);" class=""> </b></b><br class=""><b style="font-family: Arial; font-size: 13px;" class=""><b style="color: rgb(96, 96, 96);" class=""><span style="white-space: pre-wrap;" class="">        </span></b><b class=""><span style="white-space: pre-wrap;" class=""><font color="#606060" class="">        <span style="white-space: pre-wrap;" class="">        </span> </font><font color="#4f7a28" class="">.</font></span></b><b class=""><font color="#4f7a28" class="">Green: </font></b><span class=""> </span><b style="color: rgb(96, 96, 96);" class="">200</b><b class=""><font color="#e32400" class="">,</font></b><b style="color: rgb(96, 96, 96);" class=""> </b></b><br class=""><b style="font-family: Arial; font-size: 13px;" class=""><b style="color: rgb(96, 96, 96);" class=""><span style="white-space: pre-wrap;" class="">        </span></b><b style="color: rgb(96, 96, 96);" class=""><span style="white-space: pre-wrap;" class="">        <span style="white-space: pre-wrap;" class="">        </span> </span></b><b class=""><font color="#4f7a28" class="">.Blue</font><font color="#e32400" class="">: </font></b><b style="color: rgb(96, 96, 96);" class="">300</b></b><br class=""><b style="font-family: Arial; font-size: 13px;" class=""><b style="color: rgb(96, 96, 96);" class=""><span style="white-space: pre-wrap;" class="">        </span></b><b class=""><span style="white-space: pre-wrap;" class=""><font color="#606060" class="">        </font><font color="#006d8f" class="">default</font></span></b><b style="color: rgb(227, 36, 0);" class="">: </b><b style="color: rgb(96, 96, 96);" class="">-1</b><b style="color: rgb(227, 36, 0);" class=""> </b></b><br class=""><b style="font-family: Arial; font-size: 13px;" class=""><span style="color: rgb(227, 36, 0); white-space: pre-wrap;" class="">        </span>}</b><br class=""><b style="font-family: Arial; font-size: 13px;" class=""><b class=""><span style="color: rgb(96, 96, 96); white-space: pre-wrap;" class="">        </span><font color="#006d8f" class="">let</font></b><b style="color: rgb(96, 96, 96);" class=""> num = color.</b><b class=""><font color="#008cb4" class="">map </font>{</b></b><br class=""><b style="font-family: Arial; font-size: 13px;" class=""><b style="color: rgb(96, 96, 96);" class=""><span style="white-space: pre-wrap;" class="">        </span></b><b class=""><span style="white-space: pre-wrap;" class=""><font color="#606060" class="">        </font><font color="#006d8f" class="">case</font><font color="#606060" class=""> </font></span></b><b class=""><font color="#4f7a28" class="">.Red:</font></b><b style="color: rgb(227, 36, 0);" class=""> </b><b style="color: rgb(96, 96, 96);" class="">100</b></b><br class=""><b style="font-family: Arial; font-size: 13px;" class=""><b style="color: rgb(96, 96, 96);" class=""><span style="white-space: pre-wrap;" class="">        </span></b><b class=""><span style="white-space: pre-wrap;" class=""><font color="#606060" class="">        </font><font color="#006d8f" class="">case </font><font color="#606060" class=""> </font><font color="#4f7a28" class="">.</font></span></b><b class=""><font color="#4f7a28" class="">Green: </font></b><span style="font-family: Helvetica;" class=""> </span><b style="color: rgb(96, 96, 96);" class="">200</b><b style="color: rgb(96, 96, 96);" class=""> </b></b><br class=""><b style="font-family: Arial; font-size: 13px;" class=""><b style="color: rgb(96, 96, 96);" class=""><span style="white-space: pre-wrap;" class="">        </span></b><b class=""><span style="white-space: pre-wrap;" class=""><font color="#606060" class="">        </font><font color="#006d8f" class="">case</font><font color="#606060" class=""> </font></span></b><b class=""><font color="#4f7a28" class="">.Blue</font><font color="#e32400" class="">: </font></b><b style="color: rgb(96, 96, 96);" class="">300</b></b><br class=""><b style="font-family: Arial; font-size: 13px;" class=""><b style="color: rgb(96, 96, 96);" class=""><span style="white-space: pre-wrap;" class="">        </span></b><b class=""><span style="white-space: pre-wrap;" class=""><font color="#606060" class="">        </font><font color="#006d8f" class="">default</font></span></b><b style="color: rgb(227, 36, 0);" class="">: </b><b style="color: rgb(96, 96, 96);" class="">-1</b><b style="color: rgb(227, 36, 0);" class=""> </b></b><br class=""><div style="word-wrap: break-word;" class=""><div class=""><div class=""><div class=""><div class=""><div style="word-wrap: break-word;" class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div style="word-wrap: break-word;" class=""><div class=""><div class=""><div class=""><div dir="ltr" class=""><div style="word-wrap: break-word;" class=""><div dir="ltr" class=""><div style="word-wrap: break-word;" class=""><div dir="ltr" class=""><div style="font-size: 13px; margin: 0px; line-height: normal; font-family: Arial;" class=""><b class=""><span style="color: rgb(227, 36, 0); white-space: pre-wrap;" class="">        </span>}</b></div><div class=""><b class=""><br class=""></b></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=1MXK54sosN3xru3iYcLt0oBZ2w20i49gyogXctgrspdrRHVLkMj8jCRHlz8cyrwLohx0RooFPSqaCvIiTnBx2Ebpf1kBL-2F9wtFrlJOGlnG3-2F3sz-2BVmtt8bqFALsU0KayFGtK1-2BvEDmuxRePRYLKwohAdMtRcHICOopm6CZIfcVsgW0jyH7kQuY-2Fe1AzS12HQdfPTyS8cm2fw9RdmRGl4abpkRuNr95jCiPyL-2B2eEcFc-3D" alt="" width="1" height="1" border="0" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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; height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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; float: none; display: inline !important;" class=""><span class="Apple-converted-space"> </span>_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></body></html>