[swift-evolution] Strings in Swift 4

Russ Bishop xenadu at gmail.com
Fri Jan 20 00:46:37 CST 2017


> On Jan 19, 2017, at 8:20 PM, Xiaodi Wu via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Clearly too big to digest in one take. Some initial thoughts:
> 
> * Not sure about the wisdom of the ad-hoc Substring : String compiler magic. It seems that whatever needs overcoming here would be equally relevant for ArraySlice. It would be more design work, but perhaps not terribly more implementation work, to have a magical protocol that allows the compiler to apply a similar magic to conforming types (e.g. a `ImplicitlyConvertibleSlice` protocol with an associated type, to which ArraySlice and String could both conform). Alternatively, perhaps all of this is not truly necessary for sufficient ergonomics.


Well if I had my way we’d have conversion operators so you could have:

struct Substring {
    implicit conversion() -> String {
        //...
    }
}


But I was also a fan of @conversion so don’t mind me :)


Russ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170119/9755d86e/attachment.html>


More information about the swift-evolution mailing list