<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 prefer this style over “if let” & “if var”. I don’t know it is my aversion to “let” because it brings back memories of a language I would prefer to forget (BASIC), but I find the scattering of lets in other statements/expressions to a we bit annoying (especially in pattern matching). <div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 2016-01-29, at 12:54:12, Thorsten Seitz via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""></div><div class="">This is called flow typing in Ceylon and they are using "exists" for that case but testing for conformance with "is" works just the same way there. The latter is of importance because the common use of union types in Ceylon.</div><div class=""><br class=""></div><div class="">if exists foo {</div><div class=""> // foo is non-optional here</div><div class="">}</div><div class=""><br class=""></div><div class="">if foo is String {</div><div class=""> // foo is of type String here</div><div class="">}</div><div class=""><br class=""></div><div class="">-Thorsten</div><div class=""><br class="">Am 28.01.2016 um 19:08 schrieb Jacob Bandes-Storch via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>>:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""> if bind foo {</div><div class=""> // foo is non-optional in here</div><div class=""> }</div><div class=""><br class=""></div><div class=""> somethingAsync { [weak self] in</div> guard bind self else { return }<div class=""> // ...<br class=""><div class=""> }<br class=""><div class="gmail_extra"><br class=""></div><div class="gmail_extra">Elegant when you want to rebind the same name!</div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class="gmail_signature"><div dir="ltr" class=""><div class="">Jacob<br class=""></div></div></div></div>
<br class=""><div class="gmail_quote">On Thu, Jan 28, 2016 at 10:05 AM, Erica Sadun 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=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Do you realize how much confusion it would save if Swift just went with<br class="">
<br class="">
if bind foo = bar {...}<br class="">
<br class="">
with let semantics?<br class="">
<br class="">
-- Erica<br class="">
<div class="HOEnZb"><div class="h5"><br class="">
> On Jan 28, 2016, at 11:03 AM, Joe Groff via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class="">
><br class="">
><br class="">
>> On Jan 28, 2016, at 12:43 AM, Brent Royal-Gordon <<a href="mailto:brent@architechies.com" class="">brent@architechies.com</a>> wrote:<br class="">
>><br class="">
>>> We have a lot of evidence that 'if var' confuses people—a lot of users think that 'if var' and 'var' bindings in case patterns will write back to the original value when this isn't the case.<br class="">
>><br class="">
>> Can we address this with a diagnostic?<br class="">
>><br class="">
>> var bar: Int? = 1<br class="">
>> if var foo = bar {<br class="">
>> foo += 1 // Warning: Value is never used after modification (foo is a copy, not an alias)<br class="">
>> }<br class="">
>> print(bar)<br class="">
><br class="">
> Good idea.<br class="">
><br class="">
> -Joe<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="">
_______________________________________________<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="">
</div></div></blockquote></div><br class=""></div></div></div></div>
</div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></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>