<div dir="ltr">I’d be completely in favor of this. Structs for priority queues, skiplists, trees, binary search and more sorting functions would also be on my wishlist. I think Python made a very good choice in choosing to vend separate standard modules for stuff like that  instead of bloating its builtin namespace.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 31, 2017 at 2:22 PM, Hooman Mehr <span dir="ltr">&lt;<a href="mailto:hooman@mac.com" target="_blank">hooman@mac.com</a>&gt;</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>Maybe we need more than one level of standard library: The core (which is most of what we have now (but maybe not all of it) and multiple opt-in standard modules for hash functions, math, specialized data structures, etc.</div><div><div class="h5"><br><div><blockquote type="cite"><div>On Jul 31, 2017, at 11:10 AM, Taylor Swift &lt;<a href="mailto:kelvin13ma@gmail.com" target="_blank">kelvin13ma@gmail.com</a>&gt; wrote:</div><br class="m_-16665392533933857Apple-interchange-newline"><div><div dir="ltr">I’m not sure why only the stdlib is inlineable and specializable, but I believe it has something to do with ABI. I’m not an ABI expert though. I strongly disagree that a Swift Math library should be delegated to a third party. Math is “common” enough that there should really only be one “standard” implementation of it, under the direction of the Swift Project; we don’t want 5 competing third party Vector standards.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 31, 2017 at 2:02 PM, Hooman Mehr <span dir="ltr">&lt;<a href="mailto:hooman@mac.com" target="_blank">hooman@mac.com</a>&gt;</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 know. I hear you. I have some special arrangmnents to keep such things manageable, and I am not happy about how things stand right now.<div><br></div><div>What I am hoping to open up stdlib special compiler mode to other (low-level) libraries and also letting such libraries gain optimizations similar to stdlib when included in a project.<div><br></div><div>So, instead of putting things in stdlib, I want stdlib’s special privileges being made available to a certain category of third-party or internal modules.<div><div class="m_-16665392533933857h5"><br><div><br><div><blockquote type="cite"><div>On Jul 31, 2017, at 10:54 AM, Taylor Swift &lt;<a href="mailto:kelvin13ma@gmail.com" target="_blank">kelvin13ma@gmail.com</a>&gt; wrote:</div><br class="m_-16665392533933857m_204244033810488435Apple-interchange-newline"><div><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">&lt;<a href="mailto:hooman@mac.com" target="_blank">hooman@mac.com</a>&gt;</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>) -&gt; <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>) -&gt; <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>) -&gt; <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>) -&gt; <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>) -&gt; <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>) -&gt; <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>) -&gt; <span style="color:#703daa">Self</span></div><div style="margin:0px;line-height:normal;min-height:13px">    <br class="m_-16665392533933857m_204244033810488435m_5301210826314882459webkit-block-placeholder"></div><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>) -&gt; <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>) -&gt; <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>) -&gt; <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>) -&gt; <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="m_-16665392533933857m_204244033810488435h5"><div><br><div><blockquote type="cite"><div>On Jul 31, 2017, at 10:29 AM, Taylor Swift via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-16665392533933857m_204244033810488435m_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">&lt;<a href="mailto:adrian.zubarev@devandartist.com" target="_blank">adrian.zubarev@devandartist.c<wbr>om</a>&gt;</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_-16665392533933857m_204244033810488435m_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_-16665392533933857m_204244033810488435m_5301210826314882459h5"><br> <div id="m_-16665392533933857m_204244033810488435m_5301210826314882459m_-5678978844789218338bloop_sign_1501521568263739136" class="m_-16665392533933857m_204244033810488435m_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_-16665392533933857m_204244033810488435m_5301210826314882459h5"><p class="m_-16665392533933857m_204244033810488435m_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_-16665392533933857m_204244033810488435m_5301210826314882459m_-5678978844789218338clean_bq"><span><div><div></div><div><div><div class="m_-16665392533933857m_204244033810488435m_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() -&gt; Self<br>
    func cos() -&gt; Self<br>
    func tan() -&gt; Self<br>
    func asin() -&gt; Self<br>
    func acos() -&gt; Self<br>
    func atan() -&gt; Self<br>
<br></span></div>
<div><span style="font-family:monospace,monospace">    func ln()
-&gt; Self<br></span></div>
<div><span style="font-family:monospace,monospace">    func
log(base:Self) -&gt; Self<br></span></div>
<div><span style="font-family:monospace,monospace">    func
pow(exponent:Self) -&gt; Self<br></span></div>
<div><span style="font-family:monospace,monospace">    func exp()
-&gt; 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/mailma<wbr>n/listinfo/swift-evolution</a><br></div></blockquote></div><br></div></div></div></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></div></div></div></blockquote></div><br></div>
</div></blockquote></div><br></div></div></div></blockquote></div><br></div>