<div dir="ltr">Isn’t the point of standard inlineable library module to prevent the need to copy and paste code like this into every project? Currently I have a “math.swift” file I copy and paste into all of my projects, and since I occasionally update it, there exists about 15 different versions of it floating around, so I know this is not a sustainable practice.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 31, 2017 at 1:45 PM, Hooman Mehr <span dir="ltr"><<a href="mailto:hooman@mac.com" target="_blank">hooman@mac.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">I prefer an approach that preserves how I am used to seeing math expressions. I use this myself:<div><br></div><div><div style="margin:0px;font-size:11px;line-height:normal;background-color:rgb(255,255,255)"><div style="margin:0px;line-height:normal"><span style="color:#ba2da2">protocol</span> FloatingPointMath: <span style="color:#703daa">FloatingPoint</span></div><div style="margin:0px;line-height:normal">{</div><div style="margin:0px;line-height:normal"> <span style="color:#ba2da2">static</span> <span style="color:#ba2da2">func</span> sqrt(<span style="color:#ba2da2">_</span> value: <span style="color:#4f8187">Self</span>) -> <span style="color:#703daa">Self</span></div><div style="margin:0px;font-size:12px;line-height:normal;min-height:14px"><br></div><div style="margin:0px;line-height:normal"> <span style="color:#ba2da2">static</span> <span style="color:#ba2da2">func</span> sin(<span style="color:#ba2da2">_</span> value: <span style="color:#4f8187">Self</span>) -> <span style="color:#703daa">Self</span></div><div style="margin:0px;line-height:normal"> <span style="color:#ba2da2">static</span> <span style="color:#ba2da2">func</span> cos(<span style="color:#ba2da2">_</span> value: <span style="color:#4f8187">Self</span>) -> <span style="color:#703daa">Self</span></div><div style="margin:0px;line-height:normal"> <span style="color:#ba2da2">static</span> <span style="color:#ba2da2">func</span> tan(<span style="color:#ba2da2">_</span> value: <span style="color:#4f8187">Self</span>) -> <span style="color:#703daa">Self</span></div><div style="margin:0px;line-height:normal"> <span style="color:#ba2da2">static</span> <span style="color:#ba2da2">func</span> asin(<span style="color:#ba2da2">_</span> value: <span style="color:#4f8187">Self</span>) -> <span style="color:#703daa">Self</span></div><div style="margin:0px;line-height:normal"> <span style="color:#ba2da2">static</span> <span style="color:#ba2da2">func</span> acos(<span style="color:#ba2da2">_</span> value: <span style="color:#4f8187">Self</span>) -> <span style="color:#703daa">Self</span></div><div style="margin:0px;line-height:normal"> <span style="color:#ba2da2">static</span> <span style="color:#ba2da2">func</span> atan(<span style="color:#ba2da2">_</span> value: <span style="color:#4f8187">Self</span>) -> <span style="color:#703daa">Self</span></div><p style="margin:0px;line-height:normal;min-height:13px"> <br class="m_5301210826314882459webkit-block-placeholder"></p><div style="margin:0px;line-height:normal"> <span style="color:#ba2da2">static</span> <span style="color:#ba2da2">func</span> ln(<span style="color:#ba2da2">_</span> value: <span style="color:#4f8187">Self</span>) -> <span style="color:#703daa">Self</span></div><div style="margin:0px;line-height:normal"> <span style="color:#ba2da2">static</span> <span style="color:#ba2da2">func</span> log(<span style="color:#ba2da2">_</span> value: <span style="color:#4f8187">Self</span>, base: <span style="color:#4f8187">Self</span>) -> <span style="color:#703daa">Self</span></div><div style="margin:0px;line-height:normal"> <span style="color:#ba2da2">static</span> <span style="color:#ba2da2">func</span> pow(<span style="color:#ba2da2">_</span> value: <span style="color:#4f8187">Self</span>, exponent:<span style="color:#4f8187">Self</span>) -> <span style="color:#703daa">Self</span></div><div style="margin:0px;line-height:normal"> <span style="color:#ba2da2">static</span> <span style="color:#ba2da2">func</span> exp(<span style="color:#ba2da2">_</span> value: <span style="color:#4f8187">Self</span>) -> <span style="color:#703daa">Self</span></div><div style="margin:0px;line-height:normal">}</div><div><br></div></div></div><div>It does not pollute the global namespace and gives nice contextual auto-completion. And I don’t want it in the standard library: I only add the file when I need it. (it is not a separate module for optimization reasons).</div><div><div class="h5"><div><br><div><blockquote type="cite"><div>On Jul 31, 2017, at 10:29 AM, Taylor Swift via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br class="m_5301210826314882459Apple-interchange-newline"><div><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 31, 2017 at 1:23 PM, Adrian Zubarev <span dir="ltr"><<a href="mailto:adrian.zubarev@devandartist.com" target="_blank">adrian.zubarev@devandartist.<wbr>com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div id="m_5301210826314882459m_-5678978844789218338bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;margin:0px">I’m not sure how I would feel about this. To be honest I’d avoid such additional changes from the stdlib, because they really don’t belong there. Instead some `Math` module/package would be a better fit than clustering everything into stdlib until we end up also adding UI stuff.</div> <div><br></div>Furthermore, I don’t think a function would make any sense here. It really should be a computed property.<div><div class="m_5301210826314882459h5"><br> <div id="m_5301210826314882459m_-5678978844789218338bloop_sign_1501521568263739136" class="m_5301210826314882459m_-5678978844789218338bloop_sign"></div> <br></div></div></div></blockquote><div><br></div><div>I think a standard Math module would be a good idea, but only if it benefits from the same inlining and specialization as the standard library. Also squareRoot() should be moved to the Math module if it is ever created.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><div class="m_5301210826314882459h5"><p class="m_5301210826314882459m_-5678978844789218338airmail_on">Am 31. Juli 2017 um 19:03:49, Taylor Swift via swift-evolution (<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>) schrieb:</p> </div></div><blockquote type="cite" class="m_5301210826314882459m_-5678978844789218338clean_bq"><span><div><div></div><div><div><div class="m_5301210826314882459h5">
<div dir="ltr">
<div>How would people feel about adding a protocol<br>
<br>
<span style="font-family:monospace,monospace">protocol
MathFloatingPoint:FloatingPoin<wbr>t<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></span></div>
<div><span style="font-family:monospace,monospace"> func ln()
-> Self<br></span></div>
<div><span style="font-family:monospace,monospace"> func
log(base:Self) -> Self<br></span></div>
<div><span style="font-family:monospace,monospace"> func
pow(exponent:Self) -> Self<br></span></div>
<div><span style="font-family:monospace,monospace"> func exp()
-> Self<br></span></div>
<div><span style="font-family:monospace,monospace">}</span><br>
<br></div>
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></div><span>
______________________________<wbr>_________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a><br></span></div></div></span></blockquote></div></blockquote></div><br></div></div>
______________________________<wbr>_________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br></div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>