[swift-evolution] TrigonometricFloatingPoint/MathFloatingPoint protocol?

Taylor Swift kelvin13ma at gmail.com
Tue Aug 1 12:51:47 CDT 2017

On Tue, Aug 1, 2017 at 1:20 PM, Michael Ilseman <milseman at apple.com> wrote:

> On Aug 1, 2017, at 8:14 AM, Taylor Swift via swift-evolution <
> swift-evolution at swift.org> wrote:
> I’ve noticed from this and older threads that everyone agrees on what core
> libraries we want, but they never actually get built. Perennial requests
> seem to be
> - RNG and cryptography library (CryptoSwift could be a good base for this)
> A new implementation of crypto is probably a very bad idea. A blessed
> wrapping around the platform’s preferred implementation of crypto, however,
> is certainly needed.

Good point, but then again CryptoSwift has already demonstrated a demand
for a new Swift implementation and we wouldn’t be starting from scratch.

> - Generic Math library/Vector library
> This is pretty compelling.
> - Basic data structures (Tree, Balanced Tree, Heap, Queue, SkipList,
> graphs, etc)
> Which flavor/implementation of tree, balanced tree, heap, graphs are
> desirable here? The desirability of many of these structures is often
> dependent on which of many competing tradeoffs were made. Implementation
> details can dramatically shape the general applicability of a data
> structure.
> For example, it might make sense to adopt something similar to
> https://github.com/lorentey/BTree as a general underlying representation
> for some kinds of higher level collections (or the mechanisms to easily
> adapt them).
The idea wouldn’t be to cover every possible permutation of these data
structures, but provide implementations for the most commonly used

> - Modern DateTime library
> Foundation provides many of these, though I’m sure there are always
> opportunities for improvement. Do you see a specific need that cannot be
> addressed with improvements to corelibs-foundation? There’s a large amount
> of domain expertise in Foundation and they are pretty active on the mailing
> lists.

I’d be happy just with moving the datetime functionality from Foundation
into its own module. I’m really not a fan of the monolith pattern.

> - Modern String processing toolkit
> This is a huge gap in Swift’s current offerings, and I’m personally
> invested in improving the situation here. At the risk of hijacking this
> thread, do you have a good bullet list of the kinds of facilities you
> imagine useful? More specifically (and to keep the discussion scoped), are
> there any tools beyond something like good language support for regular
> expression matching and substitutions?
Pretty basic but most of what you have to import Foundation to do right
now, plus a few extras.

- trim whitespace from a string
- string formatting
    - round float to n decimal places
    - pad float to n 0s
    - left/right/center pad string with spaces
- locale aware capitalization
- defined CharacterSetsfor things like alphabeticals, numerics, whitespace
chars, etc.
- regex support would be nice
- platform-abstracted terminal colors would be nice

plus a lot of things I’m probably forgetting

> - 2D Graphics library (similar to cairo)
> - Windowing/UI library
> By this, do you mean cross-platform pure Swift rethinks? This is certainly
> interesting, but a pure Swift rethink is likely a lower priority than
> exposing bindings for existing cross-platform approaches (e.g. you
> mentinoed cairo). Like crypto, it might make sense to establish blessed
> wrappers/apinotes/overlays on top of tried-and-true open source offerings.

Currently, calling Cairo code from Swift is extremely problematic for
reasons involving memory ownership and object lifetimes. Nothing an
experienced Swift dev can’t get around, but definitely far too ugly a hack
for such a common task. The C library is simply incompatible with Swift’s
memory safety model.

> I think David Turnbull tried to get something like this started years back
> but it fizzled out pretty quick, probably because the Swift foss community
> was much smaller back then. Time to try again?
> On Tue, Aug 1, 2017 at 8:29 AM, Georgios Moschovitis <
> george.moschovitis at icloud.com> wrote:
>> > That's what's happened with the Server APIs Project
>> > https://swift.org/server-apis/
>> >
>> > I would like to see more of this, and math/BigNum seems like a good
>> candidate.
>> >
>> > Another is a modern date/time package, standing on the shoulders of
>> > https://jcp.org/en/jsr/detail?id=310 and similar.
>> + 1
>> I would also love to see standard implementation of Graph data
>> structures, at least some common protocols.
>> Dunno why this versatile data structure is not included in standard
>> libraries (similar to Map/Dictionary), Set, etc.
>> -g.
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170801/d7636e32/attachment.html>

More information about the swift-evolution mailing list