The criteria for a source-breaking change in Swift 4 are as follows:<br><br>- The existing syntax/API being changed must be actively harmful.<br>- The new syntax/API must clearly be better and not conflict with existing Swift syntax.<br>- There must be a reasonably automatable migration path for existing code.<br><br><div class="gmail_quote"><div dir="ltr">On Wed, Mar 1, 2017 at 02:30 Goffredo Marocchi <<a href="mailto:panajev@gmail.com">panajev@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto" class="gmail_msg"><div class="gmail_msg">I would think that removing confusion and simplifying + rationalising the syntax IS the definition of a breaking change justified :). I do not see how Erica's proposal is in any way contrary to the philosophy behind the language or is removing anything people really depend on now (in terms of expressive ability).</div><div id="m_5785249988793779581AppleMailSignature" class="gmail_msg"><br class="gmail_msg"></div><div id="m_5785249988793779581AppleMailSignature" class="gmail_msg">This should be nowhere near as controversial as the removal of pre and post increments and C style for loops, quite a slam dunk actually.<br class="gmail_msg"><br class="gmail_msg">Sent from my iPhone</div></div><div dir="auto" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg">On 28 Feb 2017, at 23:45, Xiaodi Wu 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 dir="ltr" class="gmail_msg">Agree. Design 1 seems like an improvement over the status quo. Barring unexpected downsides to this, it's then a question of whether the improvements are large enough to justify a breaking change.<div class="gmail_extra gmail_msg"><br class="gmail_msg"></div><div class="gmail_extra gmail_msg"><br class="gmail_msg"><div class="gmail_quote gmail_msg">On Tue, Feb 28, 2017 at 3:57 PM, David Hart via swift-evolution <span dir="ltr" class="gmail_msg"><<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br class="gmail_msg"><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">I’m happy that someone is trying to fix this small wart in the language. I’ve always wanted something like Design 1. It makes sense because we are already used to the pattern matching operator and we finally fix the inconsistencies between if/guard and switch.</div><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div class="m_5785249988793779581m_-6805359207323237388h5 gmail_msg"><div class="gmail_msg">On 28 Feb 2017, at 20:01, Erica Sadun 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_5785249988793779581m_-6805359207323237388m_-6014511703136387752Apple-interchange-newline gmail_msg"></div></div><div class="gmail_msg"><div class="gmail_msg"><div class="m_5785249988793779581m_-6805359207323237388h5 gmail_msg"><div style="word-wrap:break-word" class="gmail_msg"><div style="word-wrap:break-word" class="gmail_msg">The following draft proposal addresses one matter of substance (eliminating edge case errors by adopting at-site conditional binding) and one of style (using the pattern match operator consistently). Its discussion was deferred from Phase 1 and remains in a fairly early stage. Your feedback will help me decide whether this is a proposal I want to keep developing or one that I should set aside and focus on other matters. Thank you. -- E<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">The work-in-progress gist is here: <a href="https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c" class="gmail_msg" target="_blank">https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c</a> </div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><h1 style="box-sizing:border-box;margin-right:0px;margin-bottom:16px;margin-left:0px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255);margin-top:0px!important" class="gmail_msg">Simplifying case syntax</h1><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg"><li style="box-sizing:border-box" class="gmail_msg">Proposal: TBD</li><li style="box-sizing:border-box;margin-top:0.25em" class="gmail_msg">Author: <a href="https://github.com/erica" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none" class="gmail_msg" target="_blank">Erica Sadun</a></li><li style="box-sizing:border-box;margin-top:0.25em" class="gmail_msg">Status: TBD</li><li style="box-sizing:border-box;margin-top:0.25em" class="gmail_msg">Review manager: TBD</li></ul><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)" class="gmail_msg"><a id="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752user-content-introduction" class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752anchor gmail_msg" href="https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c#introduction" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Introduction</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">This proposal re-architects case syntax grammar to reduce potential errors and simplify unwrapping enumerations. </p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">Swift-evolution thread: <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20161024/tbd.html" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none" class="gmail_msg" target="_blank">[Pitch] Reimagining <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">guard case</code>/<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">if case</code></a></p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)" class="gmail_msg"><a id="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752user-content-motivation" class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752anchor gmail_msg" href="https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c#motivation" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Motivation</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">In its current design, Swift case binding suffers from two weaknesses.</p><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg"><li style="box-sizing:border-box" class="gmail_msg">Mixed external and internal <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">let</code>/<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">var</code> binding may introduce errors from uncommon edge cases.</li><li style="box-sizing:border-box;margin-top:0.25em" class="gmail_msg">Real-world users may not consider the parallel construction between <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">if case</code>/<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">guard case</code> with <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">switch</code>statements or naturally connect the two layouts.</li></ul><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)" class="gmail_msg"><a id="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752user-content-internal-case-binding" class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752anchor gmail_msg" href="https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c#internal-case-binding" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Internal Case Binding</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">When pattern matching, it's common to bind a variable or constant. It's uncommon but legal to use a bound value as an argument. Adopting an "always explicit, always within the parentheses" rule adds consistency and safety to Swift. </p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">Consider the following enumeration and values:</p><div class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752highlight m_5785249988793779581m_-6805359207323237388m_-6014511703136387752highlight-source-swift gmail_msg" style="box-sizing:border-box;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)"><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal" class="gmail_msg"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> An enum with one, two, or three associated values</span>
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">enum</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-en gmail_msg" style="box-sizing:border-box;color:rgb(121,93,163)">Value</span><<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">T</span>> { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">one</span>(T), <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">two</span>(T, T), <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">three</span>(T, T, T) }
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> An example with two associated values</span>
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> example2<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">Value</span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)"><</span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">Character</span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">></span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> .<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">two</span>(<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-s gmail_msg" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-pds gmail_msg" style="box-sizing:border-box">"</span>a<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-pds gmail_msg" style="box-sizing:border-box">"</span></span>, <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-s gmail_msg" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-pds gmail_msg" style="box-sizing:border-box">"</span>b<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-pds gmail_msg" style="box-sizing:border-box">"</span></span>)
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> A bound symbol</span>
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> oldValue <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-s gmail_msg" style="box-sizing:border-box;color:rgb(24,54,145)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-pds gmail_msg" style="box-sizing:border-box">"</span>x<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-pds gmail_msg" style="box-sizing:border-box">"</span></span></pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">This code's goal is to conditionally bind <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">newValue</code> and pattern match the value stored in the <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">oldValue</code> symbol. The first example succeeds. The second example compiles and runs but does not match the coder's intent. Using an external <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">let</code>creates a new <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">oldValue</code> shadow instead of pattern matching <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">oldValue</code>'s stored value.</p><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:16px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;color:rgb(51,51,51)" class="gmail_msg"><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;padding:0px;margin:0px;background-color:transparent;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal;border:0px;display:inline;overflow:visible;line-height:inherit;word-wrap:normal" class="gmail_msg">// Safe
if case .two(let newValue, oldValue) = example2 {
...
}
// Syntactically legal but incorrect
if case let .two(newValue, oldValue) = example2 {
...
}
</code></pre><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">In-parenthesis binding avoids accidental shadowing. It eliminates this class of error by adding <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">let</code> and <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">var</code> key words to each use point. This creates longer call sites but enumerations rarely contain more than three or four associated items.</p><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">Adopting point-of-use binding enhances clarity and readability. Both <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">if case let</code> and <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">if case var</code> (plus <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">case var</code>and <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">case let</code>) may look like single compound keywords rather than a combination of two distinct actions to developers unfamiliar with this syntax.</p><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)" class="gmail_msg"><a id="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752user-content-pattern-matching-with-conditional-binding" class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752anchor gmail_msg" href="https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c#pattern-matching-with-conditional-binding" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Pattern Matching with Conditional Binding</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">Swift's <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">guard case</code> and <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">if case</code> align statement design with the <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">switch</code> statement, moving the matched value to the right of an equal sign.</p><div class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752highlight m_5785249988793779581m_-6805359207323237388m_-6014511703136387752highlight-source-swift gmail_msg" style="box-sizing:border-box;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)"><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal" class="gmail_msg"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">switch</span> value {
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">enumeration</span>(<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> embedded)<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">:</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span>
}
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> .<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">enumeration</span>(<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> embedded) <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> value</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">The status quo for the <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">=</code> operator is iteratively built up in this fashion:</p><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg"><li style="box-sizing:border-box" class="gmail_msg"><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">=</code> performs assignment</li><li style="box-sizing:border-box;margin-top:0.25em" class="gmail_msg"><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">let x =</code> performs binding</li><li style="box-sizing:border-box;margin-top:0.25em" class="gmail_msg"><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">if let x =</code> performs conditional binding on optionals</li><li style="box-sizing:border-box;margin-top:0.25em" class="gmail_msg"><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">if case .foo(let x) =</code> performs conditional binding on enumerations <em style="box-sizing:border-box" class="gmail_msg">and</em> applies pattern matching</li></ul><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">Using <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">if case</code>/<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">guard case</code> in the absense of conditional binding duplicates basic pattern matching with less obvious meaning. These two statements are functionally identical:</p><div class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752highlight m_5785249988793779581m_-6805359207323237388m_-6014511703136387752highlight-source-swift gmail_msg" style="box-sizing:border-box;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)"><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal" class="gmail_msg"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> range <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">~=</span> myValue { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> } <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> simpler</span>
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> range <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> myValue { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> } <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> confusing</span></pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">Issues with the current design include:</p><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg"><li style="box-sizing:border-box" class="gmail_msg"><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">guard case</code> and <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">if case</code> look like standard non-conditional assignment statements but they are <em style="box-sizing:border-box" class="gmail_msg">not</em> assignment statements. Using the assignment operator violates the <a href="https://en.wikipedia.org/wiki/Principle_of_least_astonishment" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none" class="gmail_msg" target="_blank">principle of least astonishment</a>.<br style="box-sizing:border-box" class="gmail_msg"></li><li style="box-sizing:border-box;margin-top:0.25em" class="gmail_msg">In <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">switch</code>, a <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">case</code> is followed by a colon, not an assignment operator.</li><li style="box-sizing:border-box;margin-top:0.25em" class="gmail_msg">Swift <em style="box-sizing:border-box" class="gmail_msg">has</em> a pattern matching operator (<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">~=</code>) but does not use it here.</li><li style="box-sizing:border-box;margin-top:0.25em" class="gmail_msg"><code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">case</code> syntax is wordy. The statement includes <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">case</code>, <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">=</code>, and optionally <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">let</code>/<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">var</code> conditional binding. Design alternatives could streamline this syntax, enhance clarity, and introduce a more concise format.</li></ul><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)" class="gmail_msg"><a id="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752user-content-detailed-design" class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752anchor gmail_msg" href="https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c#detailed-design" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Detailed Design</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">This proposal adopts point-of-use conditional binding and recommends one of the following designs. A successful design will replace the current syntax with a simpler grammar that prioritizes pattern matching and support conditional binding.</p><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)" class="gmail_msg"><a id="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752user-content-design-1-using-the-pattern-matching-operator" class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752anchor gmail_msg" href="https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c#design-1-using-the-pattern-matching-operator" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Design 1: Using the Pattern Matching Operator</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">This design drops the <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">case</code> keyword and replaces <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">=</code> with <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">~=</code>. The results look like this, showcasing a variety of <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">let</code>placement, variable binding, and optional sugar alternatives.</p><div class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752highlight m_5785249988793779581m_-6805359207323237388m_-6014511703136387752highlight-source-swift gmail_msg" style="box-sizing:border-box;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)"><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal" class="gmail_msg"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">guard</span> .<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">success</span>(<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> value) <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">~=</span> result <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">else</span> { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> }
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">guard</span> .<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">success</span>(<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> value) <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">~=</span> result <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">else</span> { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> }
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> .<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">success</span>(<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> value) <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">~=</span> result { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> }
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> .<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">success</span>(<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> value) <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">~=</span> result { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> }
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">guard</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> x<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">?</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">~=</span> anOptional <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">else</span> { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> }
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> x<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">?</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">~=</span> anOptional { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> }</pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">In this design:</p><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg"><li style="box-sizing:border-box" class="gmail_msg">The <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">case</code> keyword is subsumed into the (existing) pattern matching operator</li><li style="box-sizing:border-box;margin-top:0.25em" class="gmail_msg">The statements adopt the existing <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">if-let</code>/<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">if var</code> and <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">guard-let</code>/<code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">guard var</code> syntax, including <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">Optional</code>syntactic sugar.</li></ul><div class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752highlight m_5785249988793779581m_-6805359207323237388m_-6014511703136387752highlight-source-swift gmail_msg" style="box-sizing:border-box;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)"><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal" class="gmail_msg"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> x <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> anOptional { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> } <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> current</span>
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"></span>
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> x<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">?</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> anOptional { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> } <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> would be removed</span>
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> x<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">?</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">~=</span> anOptional { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> } <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> proposed replacement for `if case`</span></pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">Pattern matching without conditional binding simplifies to a standalone Boolean condition clause. On adopting this syntax, the two identical range tests naturally unify to this single version:</p><div class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752highlight m_5785249988793779581m_-6805359207323237388m_-6014511703136387752highlight-source-swift gmail_msg" style="box-sizing:border-box;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)"><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal" class="gmail_msg"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> range <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">~=</span> myValue { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> } <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> before</span>
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">case</span> range <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> myValue { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> } <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> before</span>
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"></span>
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> range <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">~=</span> myValue { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> } <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> after</span></pre></div><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)" class="gmail_msg"><a id="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752user-content-design-2-using-a-declare-and-assign-operator" class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752anchor gmail_msg" href="https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c#design-2-using-a-declare-and-assign-operator" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Design 2: Using a Declare and Assign Operator</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">This design introduces new <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">:=</code> "declare and assign" operator. This operator eliminates the need for explicit <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">let</code>, although the keyword is allowed and most house style guides would recommend its use:</p><div class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752highlight m_5785249988793779581m_-6805359207323237388m_-6014511703136387752highlight-source-swift gmail_msg" style="box-sizing:border-box;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)"><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal" class="gmail_msg"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">guard</span> .<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">success</span>(value) <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">:</span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> result <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">else</span> { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> }
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">guard</span> .<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">success</span>(<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> value) <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">:</span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> result <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">else</span> { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> }
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> .<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">success</span>(value) <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">:</span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> result { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> }
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> .<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">success</span>(<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> value) <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">:</span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> result { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> }
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">guard</span> value<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">?</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">:</span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> anOptional <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">else</span> { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> } <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> newly legal, although unnecessary</span>
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">guard</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> value<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">?</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">:</span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> anOptional <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">else</span> { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> } <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> newly legal, although unnecessary</span></pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">Assignments to variables require the <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">var</code> keyword, enabling coders to clarify the distinct roles in mix-and-match pattern matching:</p><div class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752highlight m_5785249988793779581m_-6805359207323237388m_-6014511703136387752highlight-source-swift gmail_msg" style="box-sizing:border-box;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)"><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;margin-top:0px;margin-bottom:0px;line-height:1.45;word-wrap:normal;padding:16px;overflow:auto;background-color:rgb(247,247,247);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;word-break:normal" class="gmail_msg"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">guard</span> .<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">pair</span>(value1, <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> value2) <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">:</span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> result <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">else</span> { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> } <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> implied let</span>
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">guard</span> .<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">pair</span>(<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">let</span> value1, <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> value2) <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">:</span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> result <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">else</span> { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> } <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> explicit let</span>
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">if</span> .<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">success</span>(<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> value) <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">:</span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> result { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> } <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> variable assignment</span>
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">guard</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> x<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">?</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">:</span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> anOptional <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">else</span> { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> } <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> variable assignment</span>
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">guard</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> x <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">:</span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> anOptional <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">else</span> { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> } <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> simpler variable assignment</span>
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">guard</span> <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">var</span> x <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> anOptional <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">else</span> { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> } <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> even simpler (current) variable assignment</span>
<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"></span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">guard</span> x <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">:</span><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">=</span> anOptional <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">else</span> { <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-k gmail_msg" style="box-sizing:border-box;color:rgb(167,29,93)">...</span> } <span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box;color:rgb(150,152,150)"><span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c gmail_msg" style="box-sizing:border-box">//</span> new constant assignment</span></pre></div><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">Adopting this syntax provides more natural results for binding associated enumeration variables.</p><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)" class="gmail_msg"><a id="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752user-content-excluded-from-this-proposal" class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752anchor gmail_msg" href="https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c#excluded-from-this-proposal" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Excluded from this proposal</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">This proposal does not address <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">switch case</code> or <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">for case</code> beyond internal binding requirements.</p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)" class="gmail_msg"><a id="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752user-content-impact-on-existing-code" class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752anchor gmail_msg" href="https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c#impact-on-existing-code" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Impact on Existing Code</h2><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">This proposal is breaking and would require migration. External <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">let</code> or <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">var</code> would automatically be moved by fixits into use points. Current <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">guard case</code> and <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">if case</code> syntax would be migrated to the new design.</p><h3 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;font-size:1.25em;line-height:1.25;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)" class="gmail_msg"><a id="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752user-content-timeline" class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752anchor gmail_msg" href="https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c#timeline" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Timeline</h3><p style="box-sizing:border-box;margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="gmail_msg">Although removing <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">if case</code> and <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">guard case</code> are breaking, this proposal should wait until Swift 4 Stage two to allow proper debate and consideration from the core team.</p><h2 style="box-sizing:border-box;margin-top:24px;margin-bottom:16px;line-height:1.25;padding-bottom:0.3em;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(238,238,238);color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';background-color:rgb(255,255,255)" class="gmail_msg"><a id="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752user-content-alternatives-considered" class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752anchor gmail_msg" href="https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c#alternatives-considered" style="box-sizing:border-box;background-color:transparent;color:rgb(64,120,192);text-decoration:none;float:left;padding-right:4px;line-height:1" target="_blank"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Alternatives Considered</h2><ul style="box-sizing:border-box;padding-left:2em;margin-top:0px;color:rgb(51,51,51);font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Helvetica,Arial,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255);margin-bottom:0px!important" class="gmail_msg"><li style="box-sizing:border-box" class="gmail_msg">Leaving the grammar as-is, albeit confusing</li><li style="box-sizing:border-box;margin-top:0.25em" class="gmail_msg">Retaining <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">case</code> and replacing the equal sign with <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">~=</code> (pattern matching) or <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">:</code> (to match the switch statement).</li><li style="box-sizing:border-box;margin-top:0.25em" class="gmail_msg">Adding <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">matches</code> or <code style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.600000381469727px;padding:0.2em 0px;margin:0px;background-color:rgba(0,0,0,0.0392157);border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px" class="gmail_msg">is</code> as an alternative to the pattern matching operator</li></ul><div class="gmail_msg"><br class="gmail_msg"></div></div></div></div></div></div><span class="gmail_msg">_______________________________________________<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"></span></div></blockquote></div><br class="gmail_msg"></div><br class="gmail_msg">_______________________________________________<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">
<br class="gmail_msg"></blockquote></div><br class="gmail_msg"></div></div>
</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></div>