<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="">I <i class="">think</i>&nbsp;it’d be _<div class=""><br class=""></div><div class="">You could use it to test if the return value is non-nil, but you’d have to revert to “if let x = …” to actually use the results.</div><div class=""><br class=""></div><div class="">I think.</div><div class=""><br class=""><div class="">
- Dave Sweeris

</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On Feb 1, 2016, at 11:22, T.J. Usiyan via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="">This is interesting. What name is created by&nbsp;</div><div class=""><br class=""></div><div class=""><div style="font-size:13px" class=""><font face="Menlo" class="">&nbsp; if bind foo.somethingReturningAnOptional {</font></div><div style="font-size:13px" class=""><font face="Menlo" class="">&nbsp; &nbsp; &nbsp; // ???</font></div><div style="font-size:13px" class=""><font face="Menlo" class="">&nbsp; }</font></div></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Feb 1, 2016 at 2:18 PM, Erica Sadun via swift-evolution <span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">Joe says "<span style="font-family:Palatino-Roman" class="">If you all are serious about this, I think you should start a new thread about it."&nbsp;</span><div class="">I think it's worth a serious discussion just so it can be evaluated and either adopted or discarded</div><div class="">and dropped forever. Here goes.</div><div class=""><br class=""></div><div class="">INTRO</div><div class=""><br class=""><div class="">The <font face="Menlo" class="">if let x = x {...}</font> and <font face="Menlo" class="">guard let x = x else {...}</font> constructs do something with&nbsp;<font face="Menlo" class="">let</font> (and&nbsp;<font face="Menlo" class="">var</font>) that's&nbsp;</div><div class="">fundamentally different from <font face="Menlo" class="">let</font> (and <font face="Menlo" class="">var</font>) elsewhere in the language.&nbsp; The same keywords are used to conditionally unwrap</div><div class="">and bind an item, not just shadow that item's current value.</div><div class=""><br class=""></div><div class="">Introducing a new&nbsp;<font face="Menlo" class="">bind</font>&nbsp;keyword to indicate unwrapping and binding would disambiguate these uses.</div><div class=""><br class=""></div><div class="">DETAIL DESIGN:</div><div class=""><br class=""></div><div class="">Jacob Bandes-Storch offers two common use-cases. I prefer his "if bind foo" to my original "if bind foo = foo":</div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">&nbsp; if bind foo {</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; &nbsp; // foo is non-optional in here</font></div><div class=""><font face="Menlo" class="">&nbsp; }</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">&nbsp; somethingAsync { [weak self] in</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; &nbsp; guard bind self else { return }</font></div><div class=""><font face="Menlo" class="">&nbsp; &nbsp; &nbsp; // ...</font></div><div class=""><font face="Menlo" class="">&nbsp; }</font></div></div><div class=""><br class=""></div></div><div class="">JBS's approach offers my original "bind" keyword to unwrap and shadow bind, but also provides a way to&nbsp;</div><div class="">strongly bind a weak reference to self, which (presumably) would allow self semantics in the remaining</div><div class="">lifetime of that scope.</div><div class=""><br class=""></div><div class="">ALTERNATIVE PROPOSALS:</div><div class=""><br class=""></div><div class="">Tino Heth proposes a second use-case one with different semantics. This case, it seems to make an</div><div class="">alias rather than using binding for shadowing:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">bind x = a.property.with.a.long.path<br class="">print x &nbsp;// 42<br class="">print(a.property.with.a.long.path == 42) =&gt; true</font></div><div class=""><span style="font-family:Palatino-Roman" class=""><br class=""></span></div><div class=""><span style="font-family:Palatino-Roman" class="">presumably this means:</span></div><div class=""><span style="font-family:Palatino-Roman" class=""><br class=""></span></div><div class=""><font face="Menlo" class="">x += 1</font></div><div class=""><font face="Menlo" class="">print(a.property.with.a.long.path) &nbsp;// 43</font></div><div class=""><font face="Palatino-Roman" class=""><br class=""></font></div><div class=""><font face="Palatino-Roman" class="">DISCUSSION</font></div><div class=""><font face="Palatino-Roman" class=""><br class=""></font></div><div class=""><font face="Palatino-Roman" class="">I'm throwing these both out there. I have nothing to really say about Tino's but I do think my and Jacob's&nbsp;</font></div><div class=""><font face="Palatino-Roman" class="">proposal has the advantages of:</font></div><div class=""><font face="Palatino-Roman" class=""><br class=""></font></div><div class=""><font face="Palatino-Roman" class="">* Simplifying an mildly complex and potentially misleading statement&nbsp;</font></div><div class=""><font face="Palatino-Roman" class="">* Creating a deliberate and controlled rather than accidental shadowing style</font></div><div class=""><font face="Palatino-Roman" class=""><br class=""></font></div><div class=""><font face="Palatino-Roman" class="">Have at it.</font></div><span class="HOEnZb"><font color="#888888" class=""><div class=""><font face="Palatino-Roman" class=""><br class=""></font></div><div class=""><font face="Palatino-Roman" class="">-- Erica</font></div><div class=""><font face="Palatino-Roman" class=""><br class=""></font></div><div class=""><font face="Palatino-Roman" class=""><br class=""></font></div></font></span></div><br class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a href="mailto:swift-evolution@swift.org" 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=""></blockquote></div><br class=""></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></div></body></html>