<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Thanks Xiaodi. Interesting arguments there. It possibly seems a shame to me, because it has knock on effects of making other things more complicated. But I do see how for the most simple case of unwrapping a single Optional, it makes sense.<div class=""><br class=""></div><div class="">As much as I would like Brent’s proposal to make things easier to type, I think nesting things inside a tuple, where a reader must keep track of which input matches which output, could lead to harder to follow code.</div><div class=""><br class=""></div><div class="">In my own code I will probably stick to using the long form `guard let a = opt1, let b = opt2, let c = opt3 else { … }`, not because I would like typing it, but because it will be the most clear.</div><div class=""><br class=""></div><div class="">I would have loved for SE-0099 to have gone with semicolon/newline separators so I could write it like this, but alas:</div><div class=""><br class=""></div><div class="">guard</div><div class=""> let a = opt1</div><div class=""> let b = opt2</div><div class=""> let c = opt3</div><div class="">else {</div><div class=""> …</div><div class="">}</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">A different thought — maybe if Xcode had autocompletion to unwrap Optionals when inside an `if` or `guard` statement it would make things a lot easier. Just type the full name of the optional, then press escape, and then code will be suggested to unwrap it. Is the pain this proposal targets mainly in the writing more than reading?</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">guard opt·|·</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">guard let <#placeholder#> = opt1</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">guard let a = opt1</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">guard let a = opt1, opt2·|·</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">guard let a = opt1, let <#placeholder#> = opt2</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">guard let a = opt1, let b = opt2</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Patrick</div><div class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 14 Jun 2016, at 2:07 PM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Also, see: <a href="https://github.com/apple/swift-evolution/blob/master/commonly_proposed.md" class="">https://github.com/apple/swift-evolution/blob/master/commonly_proposed.md</a><br class=""><div class="gmail_extra"><br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Jun 13, 2016 at 11:06 PM, Xiaodi Wu <span dir="ltr" class=""><<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">This has been suggested before, I believe. The core team has weighed in several times; it seemed like there was some disagreement amongst them whether the current syntax is the wisest, but the concluding statement seemed uncontroversial: "<span style="" class="">I don't think it's something we can change."</span><div class=""><font class=""><br class=""></font></div><div class=""><font class="">Source:<br class=""></font><div class=""><a href="http://article.gmane.org/gmane.comp.lang.swift.evolution/15879/" target="_blank" class="">http://article.gmane.org/gmane.comp.lang.swift.evolution/15879/</a><br class=""><div class="gmail_extra"><br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote"><div class=""><div class="h5">On Mon, Jun 13, 2016 at 10:32 PM, Patrick Smith via swift-evolution <span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span> wrote:<br class=""></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5">
                <div style="padding-left:16px;padding-right:16px;padding-bottom:8px" class=""><div class="">If Pyry’s suggestion remained the preferred way of unwrapping a tuple, could it also become the only way for unwrapping a single item?<br class=""></div><div class=""><br class=""></div><div class="">guard case let a? = opt1 {</div><div class="">...</div><div class="">}</div><div class=""><br class=""></div><div class="">Or even shortened for matching optionals only:<br class=""><br class="">guard let a? = opt1 {</div><div class="">...</div><div class="">}</div><div class=""><br class=""></div><div class="">Or even as has often been requested, to keep the same name:</div><div class=""><br class=""></div><div class="">guard let opt1? {</div><div class="">...</div><div class="">}</div><div class=""><br class=""></div><div class="">Multiples:</div><div class=""><br class=""></div><div class="">guard let (opt1?, opt2?, opt3?) {</div><div class="">...</div><div class="">}</div><div class=""><br class=""></div><div class="">guard let (a?, b?, c?) = (opt1, opt2, opt3) {</div><div class="">...</div><div class="">}</div><div class=""><br class=""></div><div class="">Sorry, not trying to derail, but it always has seemed like something shorter and more self explanatory could be made for optionals. `?` in pattern matching is a special syntax anyway, so why not make this common use case easier?<br class=""><br class=""><div class="">Patrick</div><br class=""></div></div>
                <div class="gmail_quote">_____________________________<br class="">From: Pyry Jahkola via swift-evolution <<a dir="ltr" href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>><br class="">Sent: Sunday, June 12, 2016 10:04 PM<br class="">Subject: Re: [swift-evolution] [Draft] Tuple-Based Compound Optional Binding<br class="">To: Brent Royal-Gordon <<a dir="ltr" href="mailto:brent@architechies.com" target="_blank" class="">brent@architechies.com</a>><br class="">Cc: swift-evolution List <<a dir="ltr" href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>><div class=""><div class=""><br class=""><br class=""><br class=""><br class=""><div class=""><blockquote class=""><div class="">On 12 Jun 2016, at 14:46, Brent Royal-Gordon via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</div><br class=""><div class=""><pre style="font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;word-spacing:0px;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;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" class=""><span style="color:rgb(167,29,93)" class="">guard</span> <span style="color:rgb(167,29,93)" class="">let</span> (a, b, c) <span style="color:rgb(167,29,93)" class="">=</span> (opt1, opt2, opt3) <span style="color:rgb(167,29,93)" class="">else</span> { <span style="color:rgb(167,29,93)" class="">...</span> }</pre></div></blockquote></div><br class="">You mention `<font face="Menlo" class="">guard case</font>` in the motivation, but I think for the uninitiated reader it would be fair to point out that the following example already works equivalently, with only a few extra characters:<div class=""><br class=""></div><div class=""><pre style="font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;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" class=""><span style="color:rgb(167,29,93)" class="">guard case</span> <span style="color:rgb(167,29,93)" class="">let</span> (a?, b?, c?) <span style="color:rgb(167,29,93)" class="">=</span> (opt1, opt2, opt3) <span style="color:rgb(167,29,93)" class="">else</span> { <span style="color:rgb(167,29,93)" class="">...</span> }</pre><div class=""><br class=""></div></div><div class="">Aside of that, it's yet more magic to our `<font face="Menlo" class="">if let</font>` syntax but I don't mind, it would be useful at times.</div><div class=""><br class=""></div><div class="">— Pyry</div><div class=""><br class=""></div><br class=""><br class=""></div></div></div>
        <br class=""></div></div><span class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></span></blockquote></div><br class=""></div></div></div></div>
</blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></div></div></body></html>