<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Would you agree with the following arguments?</div><div><br>On 1 Mar 2017, at 15:57, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com">xiaodi.wu@gmail.com</a>&gt; wrote:<br><br></div><blockquote type="cite"><div>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></div></blockquote><div><br></div><div>The current pattern matching syntax is inconsistent which makes it hard even for experts to get correct (I often have to check it up) and is confusing for newcomers because of the use of the assignment operator. Both of these arguments tend to show that the existing syntax is actively harmful.</div><br><blockquote type="cite"><div>- The new syntax/API must clearly be better and not conflict with existing Swift syntax.<br></div></blockquote><div><br></div><div>Design 1:</div><div>• fixes the inconsistencies in optional pattern binding between switch and if/guard</div><div>• reduces the number of different positions the let keyword can be in for enum matching, improving its learnability</div><div>• uses an existing operator which clarifies the pattern matching intent for newcomers</div><br><blockquote type="cite"><div>- There must be a reasonably automatable migration path for existing code.<br></div></blockquote><div><br></div><div>All these changes affect syntax on expressions and can be migrated like by line without looking at the environnement of the piece of code, simplifying its migration.</div><br><blockquote type="cite"><div><div class="gmail_quote"><div dir="ltr">On Wed, Mar 1, 2017 at 02:30 Goffredo Marocchi &lt;<a href="mailto:panajev@gmail.com">panajev@gmail.com</a>&gt; 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 &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; 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">&lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt;</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 &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; 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: &nbsp;<a href="https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c" class="gmail_msg" target="_blank">https://gist.github.com/erica/06dad9bbe1a70290fe6b89a64f73bc0c</a>&nbsp;</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:&nbsp;<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.&nbsp;</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:&nbsp;<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&nbsp;<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&nbsp;<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>&nbsp;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&nbsp;<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>&nbsp;with&nbsp;<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.&nbsp;</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>&lt;<span class="m_5785249988793779581m_-6805359207323237388m_-6014511703136387752pl-c1 gmail_msg" style="box-sizing:border-box;color:rgb(0,134,179)">T</span>&gt; { <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)">&lt;</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)">&gt;</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&nbsp;<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>&nbsp;and pattern match the value stored in the&nbsp;<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>&nbsp;symbol. The first example succeeds. The second example compiles and runs but does not match the coder's intent. Using an external&nbsp;<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&nbsp;<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>&nbsp;shadow instead of pattern matching&nbsp;<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&nbsp;<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>&nbsp;and&nbsp;<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>&nbsp;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&nbsp;<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>&nbsp;and&nbsp;<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>&nbsp;(plus&nbsp;<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&nbsp;<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&nbsp;<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>&nbsp;and&nbsp;<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>&nbsp;align statement design with the&nbsp;<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>&nbsp;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&nbsp;<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>&nbsp;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>&nbsp;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>&nbsp;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>&nbsp;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>&nbsp;performs conditional binding on enumerations&nbsp;<em style="box-sizing:border-box" class="gmail_msg">and</em>&nbsp;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&nbsp;<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>&nbsp;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>&nbsp;and&nbsp;<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>&nbsp;look like standard non-conditional assignment statements but they are&nbsp;<em style="box-sizing:border-box" class="gmail_msg">not</em>&nbsp;assignment statements. Using the assignment operator violates the&nbsp;<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&nbsp;<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&nbsp;<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>&nbsp;is followed by a colon, not an assignment operator.</li><li style="box-sizing:border-box;margin-top:0.25em" class="gmail_msg">Swift&nbsp;<em style="box-sizing:border-box" class="gmail_msg">has</em>&nbsp;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>&nbsp;syntax is wordy. The statement includes&nbsp;<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>,&nbsp;<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&nbsp;<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>&nbsp;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&nbsp;<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>&nbsp;keyword and replaces&nbsp;<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>&nbsp;with&nbsp;<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&nbsp;<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&nbsp;<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>&nbsp;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&nbsp;<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>&nbsp;and&nbsp;<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>&nbsp;syntax, including&nbsp;<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&nbsp;<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>&nbsp;"declare and assign" operator. This operator eliminates the need for explicit&nbsp;<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&nbsp;<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>&nbsp;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&nbsp;<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>&nbsp;or&nbsp;<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>&nbsp;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&nbsp;<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>&nbsp;or&nbsp;<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>&nbsp;would automatically be moved by fixits into use points. Current&nbsp;<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>&nbsp;and&nbsp;<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>&nbsp;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&nbsp;<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>&nbsp;and&nbsp;<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>&nbsp;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&nbsp;<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>&nbsp;and replacing the equal sign with&nbsp;<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>&nbsp;(pattern matching) or&nbsp;<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>&nbsp;(to match the switch statement).</li><li style="box-sizing:border-box;margin-top:0.25em" class="gmail_msg">Adding&nbsp;<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>&nbsp;or&nbsp;<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>&nbsp;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>
</div></blockquote></body></html>