<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 Feb 13, 2016, at 10:39 PM, Andrew Bennett <<a href="mailto:cacoyi@gmail.com" class="">cacoyi@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Fantastic idea, it would be nice to be able to do this in such a way that it didn't bloat out a function's definition. This is similar to the code-by-contract discussions that have happened in the past. This may be breaking into macro territory though. Perhaps it could be expressed like this:</div></div></blockquote><div><br class=""></div><div>BTW, you might want to check out this related work as well:</div><div><br class=""></div><div><a href="http://types.cs.washington.edu/checker-framework/" class="">http://types.cs.washington.edu/checker-framework/</a></div><div><a href="http://types.cs.washington.edu/checker-framework/tutorial/webpages/user-input-eclipse.html" class="">http://types.cs.washington.edu/checker-framework/tutorial/webpages/user-input-eclipse.html</a></div><div><a href="http://types.cs.washington.edu/checker-framework/current/checker-framework-manual.html#writing-a-checker" class="">http://types.cs.washington.edu/checker-framework/current/checker-framework-manual.html#writing-a-checker</a></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""><br class=""></div><div class=""><font face="monospace, monospace" class="">@callVerification func verifyNoLiterals(inNode node: ASTNode) -> [CallVerificationError] {</font></div><div class=""><font face="monospace, monospace" class=""> ...</font></div><div class=""><font face="monospace, monospace" class="">}</font></div><div class=""><font face="monospace, monospace" class=""><br class=""></font></div><div class=""><font face="monospace, monospace" class="">@verifyCall(noLiterals)</font></div><div class=""><span style="font-size:13px" class=""><font face="monospace, monospace" class="">func precondition(success: Bool) {</font></span></div><div class=""><span style="font-size:13px" class=""><font face="monospace, monospace" class=""> ...</font></span></div><div class=""><span style="font-size:13px" class=""><font face="monospace, monospace" class="">}</font></span><br class=""></div><div class=""><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Sat, Feb 13, 2016 at 8:15 AM, Amir Michail 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"><div style="word-wrap:break-word" class="">For example, the Swift standard library might want to ensure that you use "preconditionFailure()" instead of "precondition(false)" since the former doesn’t get in the way of constant/variable initialization static analysis.<div class=""><br class=""></div><div class="">So maybe allow functions to have a warning clause with an abstract syntax tree parameter allowing the function to examine its usage context in the source code and issue warnings correspondingly that appear during the compile.</div><div class=""><br class=""></div><div class="">Here’s some related work: <a href="https://msdn.microsoft.com/en-us/magazine/dn879356.aspx" target="_blank" class="">https://msdn.microsoft.com/en-us/magazine/dn879356.aspx</a></div><div class=""><br class=""></div></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>
</div></blockquote></div><br class=""></body></html>