[swift-evolution] Strings in Swift 4
Dave Abrahams
dabrahams at apple.com
Wed Feb 22 19:24:31 CST 2017
Equally a non-starter. All known threadsafe schemes that require caches to be updated upon non-mutating operations have horrible performance issues, and further this would penalize all string code by reserving space for the cache and filling it even for the vast majority of operations that don't require random access. Trust me, we've gotten lots of such suggestions and thought through the implications of each one very carefully. I'm afraid you will have to accept being disappointed about this.
More generally, there's a reason that the collection model has bidirectional and random access distinctions: important data structures are inherently not random access. Heroic attempts to present the illusion that they are randomly-accessible are not going to fly. These abstractions always break down, leaking the true non-random-access nature in often unpredictable ways, penalizing lots of code for the sake of a very few use-cases, and introducing complexity that is hard for the optimizer to digest and makes it painful (sometimes impossible) to grow and evolve the library.
This should be seen as a general design philosophy: Swift presents abstractions that harmonize with, rather than hide, the true nature of things.
>From me, the answer remains "no."
Sent from my moss-covered three-handled family gradunza
> On Feb 22, 2017, at 1:40 PM, Ted F.A. van Gaalen <tedvgiosdev at gmail.com> wrote:
>
> What about having a (lazy) Array<Character> property inside String?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170222/7db939a9/attachment.html>
More information about the swift-evolution
mailing list