[swift-evolution] Pitch: Renaming CharacterSet to UnicodeScalarSet

Xiaodi Wu xiaodi.wu at gmail.com
Wed Sep 28 16:58:41 CDT 2016

Is this really correct? Character and UnicodeScalar are not synonyms. The
Character type represents a character made up of one or more Unicode
scalars (i.e. an extended grapheme cluster). Is a CharacterSet a set of
Unicode-compliant characters that happens to be restricted to those
characters each made up of only a single Unicode scalar, or is it meant to
be a set of Unicode scalars? My read of the Foundation documentation is
that it is the former.

On Wed, Sep 28, 2016 at 4:27 PM, Erica Sadun via swift-evolution <
swift-evolution at swift.org> wrote:

> Chris: "*Also, it is worth saying that any source breaking change still
> has to have an *
> *ultra-compelling reason to be worth considering.  Despite having a
> framework to *
> *support some source breaking changes, we still want to minimize them
> where *
> *ever possible.*"
> Since it seems to be open season on introducing a few, highly focused
> breaking changes, let me throw this one out there.
> *Pitch: Renaming CharacterSet to UnicodeScalarSet*
> In Swift, String is defined as "a Unicode string value." and a
> "CharacterSet"
> represents a set of Unicode-compliant characters.
> A CharacterSet's initializers are:
>    - init()
>    - init<S>(S)
>    - init(arrayLiteral: UnicodeScalar...)
>    - init(bitmapRepresentation: Data)
>    - init(charactersIn: ClosedRange<UnicodeScalar>)
>    - init(charactersIn: String)
>    - init(charactersIn: Range<UnicodeScalar>)
>    - init?(contentsOfFile: String)
> Why not rename `CharacterSet` to `UnicodeScalarSe`t, and update the
> initializers
> to reflect they're being initialized from the unicode scalars in strings
> and ranges?
> I think the few places where the word `character` is left mentioned (in
> convenience
> properties) can be better named from `punctuationCharacters` to
> `punctuation`,
> `controlCharacters` to `controlAndFormat`, etc.
> -- E
> _______________________________________________
> 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/20160928/55373012/attachment.html>

More information about the swift-evolution mailing list