<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="">Yes! (As far as I’m concerned.) Operating on scopes was what I originally had in mind, but I then overlooked the # modifier approach.<div class=""><br class=""></div><div class="">—CK</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 7, 2016, at 2:10 PM, Jacob Bandes-Storch &lt;<a href="mailto:jtbandes@gmail.com" class="">jtbandes@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Would these be more appropriate as scoped modifiers similar to #available(...)?<div class=""><br class=""></div><div class="">&nbsp; &nbsp; func foo() {<br class="">&nbsp; &nbsp; &nbsp; &nbsp; ...</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; #unchecked {<br class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // stuff in here is unchecked</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class="">&nbsp; &nbsp; }</div><div class="gmail_extra"><div class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div></div></div></div>
<br class=""><div class="gmail_quote">On Thu, Jan 7, 2016 at 1:55 PM, Charles Kissinger 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">I wanted to float the idea of adding new attributes for function and method declarations that would allow various safety checks to be turned off (or on) at the level of individual functions. Examples of such attributes would be:<br class="">
<br class="">
@uncheckedmath&nbsp; // integer overflow<br class="">
@uncheckedbounds&nbsp; // array bounds<br class="">
@unchecked&nbsp; &nbsp; &nbsp; // no safety checks, equivalent to -Ounchecked<br class="">
@fastmath&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// if the —fastmath compiler option becomes available in the future<br class="">
<br class="">
These attributes could have an argument with a value of true or false, allowing the global compiler option to be overridden for particular functions.<br class="">
<br class="">
This is primarily motivated by the fact that the -Ounchecked compiler option is a very blunt instrument. It globally disables several unrelated safety checks such as integer overflow and array bounds checking. And it operates only at the level of an entire compilation unit. It is hard to reason about all the effects of this option across a large module, and isolating specific code to be compiled separately with -Ounchecked is inconvenient.<br class="">
<br class="">
These new attributes would allow specific safety checks to be enabled or disabled on a per-function basis. I think the overall effect would be safer programs, because developers would be less likely to resort to the global -Ounchecked compiler option when searching for better performance.<br class="">
<br class="">
Are optimization attributes such as these feasible?<br class="">
<br class="">
-CK<br class="">
<br 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="">
</blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></div></body></html>