<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 31, 2016 at 4:44 PM, Erica Sadun <span dir="ltr"><<a href="mailto:erica@ericasadun.com" target="_blank">erica@ericasadun.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On Oct 31, 2016, at 1:51 PM, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
><br>
> An alternative that would seem to satisfy some objections is to have a distinct "unwrap" statement--as in: "unwrap x else { ... }".<br>
<br>
</span>I'd be against this alternative as it is doing the work of a guard statement (including the "must exit scope" rule) with a new keyword and unneeded redundancy.<br>
<br>
Adding "unwrap" is local. It performs one very common task with added safety (avoids unintended shadow effects) and introduces succinctness and clarity. In other words, it is a highly focused changed with a measurable benefit in use.<br></blockquote><div><br></div><div>Sure, I have no beef with `guard unwrap`. My point was that, if there's a push for a more succinct statement, it must be `unwrap x` and not `guard x` or `guard let x` for the same reasons we've discussed above.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Compare:<br>
<br>
* "Introduce the unwrap statement that acts like guard but is limited to optionals" creates unnecessary language verbosity.<br>
<br>
* "guard x else ", meaning "treat optional values differently than all other items in a conditional list", fails because it obscures rather than adds intent. Worse, it would lead to issues with Boolean optionals whose wrapped value is later used within the same condition.<br>
<br>
Xiaodi, you mentioned an alternative approach and I'd love a peek at what that is.<br></blockquote><div><br></div><div>Not for unwrapping; for enums. I'll write you offlist :)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="HOEnZb"><font color="#888888">
-- Erica<br>
<br>
<br>
</font></span></blockquote></div><br></div></div>