[swift-evolution] [Draft] Fix a typo in two String methods

Xiaodi Wu xiaodi.wu at gmail.com
Sun Jul 24 19:25:33 CDT 2016


On Sun, Jul 24, 2016 at 7:09 PM, Dave Abrahams <dabrahams at apple.com> wrote:

>
> on Sun Jul 24 2016, Saagar Jha <saagarjha28-AT-gmail.com> wrote:
>
> > Ahh…I agree in that case; something like `utf8Array` might be a better
> > choice.
>
>   Array(s.utf8)
>
> seems expressive enough to me, if what you really want is an array.  IMO
> we should consider dropping other spellings.
>

One reason why `nullTerminatedUTF8` is a pretty good name, IMO:
Array(s.utf8) is exactly one element short of Array(s.nullTeminatedUTF8),
that being the null terminator. Incidentally, Array(s.utf8) is actually a
little problematic, afaict, as its inferred type is Array<_Element>,
whatever that is. Array<UTF8.CodeUnit>(s.utf8) works though.


> > Saagar Jha
> >
> >> On Jul 24, 2016, at 16:44, Xiaodi Wu <xiaodi.wu at gmail.com> wrote:
> >>
> >> On Sun, Jul 24, 2016 at 6:42 PM, Saagar Jha <saagarjha28 at gmail.com
> <mailto:saagarjha28 at gmail.com>> wrote:
> >> Well, yes, but hardly anyone calls it a “char array” unless they’re
> >> trying to emphasize the fact that it’s not being used as a String.
> >>
> >> I was woefully unclear with that last email. IMO, `utf8CString` is
> >> fine, since a CString really is a null-terminated array of
> >> CChars. But `utf8String` implies that the property is a String,
> >> which `nulTerminatedUTF8` is not (it's a
> >> `ContiguousArray<UTF8.CodeUnit>`).
> >>
> >> Saagar Jha
> >>
> >>
> >>
> >>> On Jul 24, 2016, at 15:58, Xiaodi Wu via swift-evolution
> >>> <swift-evolution at swift.org <mailto:swift-evolution at swift.org>>
> >>> wrote:
> >>>
> >>> On Sun, Jul 24, 2016 at 5:34 PM, Erica Sadun via swift-evolution
> >>> <swift-evolution at swift.org <mailto:swift-evolution at swift.org>>
> >>> wrote:
> >>>
> >>> > On Jul 24, 2016, at 3:45 PM, Dave Abrahams via swift-evolution
> >>> > <swift-evolution at swift.org <mailto:swift-evolution at swift.org>>
> >>> > wrote:
> >>> >
> >>> > Xiaodi Wu via swift-evolution <swift-evolution at ...> writes:
> >>> >
> >>> >
> >>> >> In `String`, the methods `nulTerminatedUTF8` and
> >>> >> nulTerminatedUTF8CString` have the word "null" misspelled
> >>> >
> >>> > Whoa. Isn't "Cstring" redundant with "null-terminated?"
> >>>
> >>> One would hope so. A series of characters terminated by a zero byte.
> >>>
> >>>   /// A contiguously stored null-terminated UTF-8 representation of
> >>>   /// the string.
> >>>   ///
> >>>   /// This is a variation on nulTerminatedUTF8 that creates an array
> >>>   /// of element type CChar for use with CString API's.
> >>>
> >>> I think utf8String and utf8CString capture both meanings. I know
> they're
> >>> a little redundant but they get the meaning across, use CString term of
> >>> art, and are pithy compared to any alternatives (like
> "representation", etc)
> >>>
> >>> They're arrays though, not strings.
> >>>
> >>> -- E
> >>>
> >>>
> >>> _______________________________________________
> >>> swift-evolution mailing list
> >>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> >>> https://lists.swift.org/mailman/listinfo/swift-evolution <
> https://lists.swift.org/mailman/listinfo/swift-evolution>
> >>>
> >>> _______________________________________________
> >>> swift-evolution mailing list
> >>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
> >>> https://lists.swift.org/mailman/listinfo/swift-evolution <
> https://lists.swift.org/mailman/listinfo/swift-evolution>
> >>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160724/0de60c11/attachment.html>


More information about the swift-evolution mailing list