<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 25, 2016, at 10:38 AM, Jay Abbott 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=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class="">I mentioned this in passing on a <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20161024/028371.html" class="">different thread</a>. Although it caused some slight confusion when I first learned the 'guard' keyword, it was easy to overcome and I didn't think the issue was strong enough to warrant a change. However, after reading the other discussion on that thread (around the possibility of a 'matches' keyword and how code is "read out" or "internally verbalised"), and seeing how passionate everyone here is about Swift, I'm thinking that maybe it should be changed.<br class=""><br class=""></div>The issue is that in English, 'guard' has an inverted logical connotation to how it is used in Swift. For example, take this sentence:<br class=""><br class=""></div>"In some functions it's a good idea is to put some checks in place, in order to guard against invalid input values."<br class=""><br class=""></div><div class=""></div>Swift's 'guard' keyword is to <b class="">guard</b> against <b class="">invalid</b> values.<br class=""></div>Or to put it another way, to <b class="">ensure</b> that we have <b class="">valid</b> values.<br class=""><br class=""></div>However, the way it reads in Swift, we <b class="">guard</b> that we have <b class="">valid</b> values.<br class=""><br class=""></div>I fully understand and agree that it's better to state the <b class="">true</b> condition for <b class="">valid</b> values here, using <b class="">else</b> to perform a contingency. And I understand why the word 'guard' was picked (given the above example sentence). I just think that 'ensure' would be better.<br class=""><br class=""></div>ensure x &gt; 0 else {<br class=""></div>&nbsp;&nbsp;&nbsp; return<br class=""><div class="">}<br class=""><br class=""></div><div class="">ensure camp.isSafe else {<br class=""></div><div class="">&nbsp;&nbsp;&nbsp; runForTheHills()<br class="">}<br class=""></div><div class=""><div class=""><br class=""></div><div class="">ensure let thingy = object as? Thingy else {<br class=""></div><div class="">&nbsp;&nbsp;&nbsp; return ExamineThingyResult.NotAThingy<br class=""></div><div class="">}<br class=""><br class=""></div><div class="">As I said, I thought it was too small a niggle to worry about, but seeing how people on here care so much about making Swift better, and the willingness to change things, I thought I'd suggest it. Although it would be a breaking change, the code changes are easy.<br class=""><br class=""></div><div class="">So what do people think? In particular it would be interesting to hear from non-native English speakers on this, did 'guard' confuse you or did 'guard' cause your understanding of the English word to be confused?</div></div></div></div></blockquote></div><br class=""><div class="">“Guard” is a computer science term for a test that must pass for execution to continue. Given that, I don’t think changing the keyword is warranted.</div><div class=""><br class=""></div><div class="">Preston</div></body></html>