<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><br></div><div>On Aug 2, 2017, at 4:29 PM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com">xiaodi.wu@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">On Wed, Aug 2, 2017 at 6:17 PM, David Sweeris <span dir="ltr"><<a href="mailto:davesweeris@mac.com" target="_blank">davesweeris@mac.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><br></div><div><div><br><br>Sent from my iPad</div><span class="">On Aug 2, 2017, at 3:43 PM, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> wrote:<br><br></span></div><span class=""><blockquote type="cite"><br><div class="gmail_quote"><div dir="auto">On Wed, Aug 2, 2017 at 17:37 Nicolas Fezans <<a href="mailto:nicolas.fezans@gmail.com" target="_blank">nicolas.fezans@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>I think that the items mentioned earlier in the list (just reminded below) should not all be treated equally.<br></div><div><br></div><div><div style="font-size:12.800000190734863px"><div><div><div></div></div></div></div></div></div><div><div><div style="font-size:12.800000190734863px"><div><div><div><div>- RNG and cryptography library (CryptoSwift could be a good base for this)<br></div>- Generic Math library/Vector library<br></div></div></div></div></div></div><div><div><div style="font-size:12.800000190734863px"><div><div>- Basic data structures (Tree, Balanced Tree, Heap, Queue, SkipList, graphs, etc)<br></div></div></div></div></div><div><div><div style="font-size:12.800000190734863px"><div><div></div>- Modern DateTime library<br></div></div></div></div><div><div><div style="font-size:12.800000190734863px"><div>- Modern String processing toolkit<br></div>- 2D Graphics library (similar to cairo)<br></div></div></div><div><div><div style="font-size:12.800000190734863px"></div><span style="font-size:12.800000190734863px">- Windowing/UI library</span><br></div><div><span style="font-size:12.800000190734863px"><br></span></div><div><span style="font-size:12.800000190734863px">By that I mean that I see at least one distinction to make between:</span></div><div><span style="font-size:12.800000190734863px"><br></span></div><div><span style="font-size:12.800000190734863px">a) the libraries that would make Swift and the programmer experience with these libraries under Swift significantly better if they are (or at least feel) deeply integrated in the language (for instance with associated </span><span style="font-size:12.800000190734863px">syntax / </span><span style="font-size:12.800000190734863px">syntax sugar)</span></div><div><span style="font-size:12.800000190734863px"> and </span></div><div><span style="font-size:12.800000190734863px">b) those that would not really benefit from such an integration to the language.</span></div><div><span style="font-size:12.800000190734863px"><br></span></div><div><span style="font-size:12.800000190734863px">For me a core math library, clearly belongs to category a)</span></div><div><span style="font-size:12.800000190734863px">I am of course not talking about a syntax sugar to call a sin or cos function, but rather to manipulate other objects such as N-dimensional matrices, defining maths functions that can take such matrices as argument e.g. sin(A) with A as matrix produces a matrix of the same size where all elements are the sinus values of the elements of A (sorry but things like this calling map() with 'sin' looks quite ugly for scientists).</span></div><div><span style="font-size:12.800000190734863px">Such a good math syntax should be compact enough to have complete equations looking "close enough" to the maths equations you could have written in a LaTeX or Word documentation of your scientific code. IMO a well integrated swift core math library should feel a Julia or Matlab code (while still having the power of Swift in terms of speed and modern programming paradigms) instead of looking and feeling like 'numpy'. But the latter is what you get if you just make a math library with no integration to the language syntax, operators, and basic functions.</span></div><div><span style="font-size:12.800000190734863px"></span></div></div></blockquote><div dir="auto"><br></div><div dir="auto">I agree that if this would require compiler support, then it needs to be part of the standard library. However, I don't see anything about what you describe that cannot be supported as a third-party library.</div></div></blockquote><br></span><div>Getting the syntax right could possibly require some compiler changes. Maybe. Depends on what "right" means. Declaring a variable, x, to be "the set of all real numbers such that x*sin(x) is an integer" using syntax like this, "let x = {x <span style="background-color:rgba(255,255,255,0)">∈ ℝ | x * sin(x) ∈ ℕ}", would be neat (I'm a bit hazy on my set notation... that might not actually be correct).</span></div><div><span style="background-color:rgba(255,255,255,0)">We're actually not that far off from that, compiler-wise, I mean. Aside defining the relevant types, operators, and identifiers, that exact syntax pretty much just requires the compiler to allow using a certain types of variables in their own declaration and either one heck of an `ExpressibleByClosureLiteral` protocol, or improvements to the type inference engine.</span></div><div><span style="background-color:rgba(255,255,255,0)"></span></div></div></blockquote></div><br></div><div class="gmail_extra">We must prioritize features that make the biggest impact for the general community, however. Swift still lacks ABI stability, ownership, concurrency, etc. In terms of math facilities, we still don't have a model for dealing with floating point errors. And, yes, there are improvements to be made in terms of having consistent special functions (sin, cos) in Swift (Glibc and Darwin don't always give you the same answer). All of these things represent sorely needed yet large undertakings; none of these require more syntax.</div></div>
</div></blockquote><br><div>Oh, I know. I wasn't claiming that we need massive compiler changes right now or anything, just providing an example of a syntax that a hypothetical "CoreMath" type of library might want to support which can't currently be made into legal swift code. </div><div><br></div><div>- Dave Sweeris </div></body></html>