<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="">Another problem that I perceive with the scoped approach (and global state) is that it can't reach inside C (or Objective-C) functions.<div class=""><div class="">
<br class="Apple-interchange-newline"><span style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;" class="">Félix</span>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">Le 4 mars 2016 à 12:53:28, Joe Groff via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class=""><blockquote type="cite" class="">On Mar 4, 2016, at 5:11 AM, Ted F.A. van Gaalen <<a href="mailto:tedvgiosdev@gmail.com" class="">tedvgiosdev@gmail.com</a>> wrote:<br class=""><br class="">Hi Joe,<br class=""><br class="">to just fuzzy compare 2 floating point numbers,<br class="">the solution you describe uses<br class="">- 2 functions, with therein 6 calls to frexp, abs, max and scalb...<br class="">isn’t that overkill ? <br class=""></blockquote><br class="">That's how APL-style tolerance is defined—the tolerance is scaled to the greater exponent of the operands. frexp, scalb, and fabs all reduce to bitwise operations on the float representation, so this should be possible to compile down to something cheap (if LLVM can't do it natively, then by hand, at least).<br class=""><br class=""><blockquote type="cite" class="">I still think a compiler directive embedded in sources at desired locations as e.g.<br class=""><br class="">@setFLoatingPointTolerance: 0.0001 <br class=""> . <br class=""> if a == b <br class=""> ...<br class="">@setFloatingPointToleranceOff<br class=""> …<br class="">@setFLoatingPointTolerance: 0.04 <br class=""> . <br class=""> if temperature == roomTemperature <br class=""> ...<br class="">@setFloatingPointToleranceOff<br class=""><br class="">So every floating point compare in source between these directives will be <br class="">will be compiled differently.<br class="">Leave it to the compiler, so no special functions/ parameters are needed,<br class="">and would be far more efficient I think.<br class=""></blockquote><br class="">We don't do this anywhere else, and I'm not sure this narrow use case justifies such an invasive change to how functions work. There might be an interesting general purpose feature in supporting implicit context arguments (beyond the usual 'self' for methods).<br class=""><br class="">-Joe<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="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></div></blockquote></div><br class=""></div></body></html>