<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 31, 2017 at 1:19 PM, Benjamin Spratling <span dir="ltr">&lt;<a href="mailto:bspratling@mac.com" target="_blank">bspratling@mac.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">1) Why would cos, sin, ln, tan, asin, acos, atan and  exp be functions and not computed properties?<br>
2) For people who uses these features on paper and text books, writing them as what we call global functions is standard.  Seeing them the same in both places reduces the translation they must do, and thus reduces accidental errors, and reduces the difficulty of reading and validating code.<br>
<br>
-Ben<br></blockquote><div><br></div><div>My first thought was to have them as free functions, but the trend in the Swift stdlib seems to be to go with namespaced protocol methods. For example, squareRoot() and signum() are methods, not toplevel functions. (I have no idea why abs() is a free function though.) Also, as to why they are functions and not computed properties, I would have suggested making them computed properties but I believe there was a big fuss a while back about why signum() had to be a method and not a property so I’m just going off of that.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Sent from my iPhone.<br>
<div><div class="gmail-h5"><br>
&gt; On Jul 31, 2017, at 1:03 PM, Taylor Swift via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br>
&gt;<br>
&gt; How would people feel about adding a protocol<br>
&gt;<br>
&gt; protocol MathFloatingPoint:<wbr>FloatingPoint<br>
&gt; {<br>
&gt;     func sin() -&gt; Self<br>
&gt;     func cos() -&gt; Self<br>
&gt;     func tan() -&gt; Self<br>
&gt;     func asin() -&gt; Self<br>
&gt;     func acos() -&gt; Self<br>
&gt;     func atan() -&gt; Self<br>
&gt;<br>
&gt;     func ln() -&gt; Self<br>
&gt;     func log(base:Self) -&gt; Self<br>
&gt;     func pow(exponent:Self) -&gt; Self<br>
&gt;     func exp() -&gt; Self<br>
&gt; }<br>
&gt;<br>
&gt; to the standard library? Float and Double would then be made to conform by default using Swift implementations instead of having to import Glibc / Darwin and writing the extensions, depending on platform.<br>
</div></div>&gt; ______________________________<wbr>_________________<br>
&gt; swift-evolution mailing list<br>
&gt; <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
&gt; <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
</blockquote></div><br></div></div>