<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"><<a href="mailto:bspratling@mac.com" target="_blank">bspratling@mac.com</a>></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>
> On Jul 31, 2017, at 1:03 PM, Taylor Swift via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br>
><br>
> How would people feel about adding a protocol<br>
><br>
> protocol MathFloatingPoint:<wbr>FloatingPoint<br>
> {<br>
> func sin() -> Self<br>
> func cos() -> Self<br>
> func tan() -> Self<br>
> func asin() -> Self<br>
> func acos() -> Self<br>
> func atan() -> Self<br>
><br>
> func ln() -> Self<br>
> func log(base:Self) -> Self<br>
> func pow(exponent:Self) -> Self<br>
> func exp() -> Self<br>
> }<br>
><br>
> 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>> ______________________________<wbr>_________________<br>
> swift-evolution mailing list<br>
> <a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
> <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>