[swift-evolution] [Review] SE-0130: Replace repeating Character and UnicodeScalar forms of String.init

Boris Wang kona.ming at gmail.com
Sat Jul 23 07:30:51 CDT 2016


The new API is useful for initializing string by pattern.
But should not replace the old API.

The reason we need 'as' is there's no character literal, like 'a' , '\nnnn'
in other languages.


Haravikk via swift-evolution <swift-evolution at swift.org>于2016年7月23日
周六19:59写道:

> On 22 Jul 2016, at 21:23, Chris Lattner via swift-evolution <
> swift-evolution at swift.org> wrote:
> * What is your evaluation of the proposal?
>
>
> I think I'm generally in favour (see later).
>
> * Is the problem being addressed significant enough to warrant a change to
> Swift?
>
>
> It's pretty minor but disproportionately annoying, so worth addressing.
>
> * Does this proposal fit well with the feel and direction of Swift?
>
>
> This I'm not sure on, partly because no alternatives are given. In
> particular I'm wondering whether this could be addressed instead by adding
> a string literal version of the initialiser, as this should I think giving
> the compiler an exact match to select instead?
>
> It's tough to weigh in on which is better though, as I don't use this much
> at all; I do however have a couple of uses of the Character initialiser
> that I'd be very slightly inconvenienced by if they were removed, but
> hardly upset about. I just wanted to float that I believe this may be an
> alternative that hasn't been considered:
>
> public init(repeating repeatedValue:StringLiteralType, count:Int) { … }
> public mutating func append(_ other:StringLiteralType) { … }
>
> But both alternatives are sufficiently Swift-y, and I'm not too bothered
> either way so long as the ambiguity is addressed.
> _______________________________________________
> 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/20160723/101813a4/attachment.html>


More information about the swift-evolution mailing list