[Draft] Fix a typo in two String methods


(Xiaodi Wu) #1

World's shortest proposal:

*Introduction*

In `String`, the methods `nulTerminatedUTF8` and `nulTerminatedUTF8CString`
have the word "null" misspelled

*Motivation*

There is a typo

*Proposed solution*

Fix the typo

*Impact on existing code*

Emit a fix-it for existing code

*Alternatives considered*

Keep on spelling "nul" without the second "l"

*Acknowledgments*

Thanks to Andrew Trick for confirming that the existing spelling is bizarre


(Jacob Bandes-Storch) #2

+1

···

On Sat, Jul 23, 2016 at 1:41 PM, Xiaodi Wu via swift-evolution < swift-evolution@swift.org> wrote:

World's shortest proposal:

*Introduction*

In `String`, the methods `nulTerminatedUTF8` and
`nulTerminatedUTF8CString` have the word "null" misspelled

*Motivation*

There is a typo

*Proposed solution*

Fix the typo

*Impact on existing code*

Emit a fix-it for existing code

*Alternatives considered*

Keep on spelling "nul" without the second "l"

*Acknowledgments*

Thanks to Andrew Trick for confirming that the existing spelling is bizarre

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Xiaodi Wu) #3

In the context of character sets, "nul" is the correct name for the 0
value. "null" only makes sense when we are talking about pointer-like
references.

Oh, I see: "NUL-terminated" is a thing because "NUL" is the ASCII name.
Still a little bizarre looking, though, especially if it's UTF8 rather than
ASCII. I am less bothered by it now, thanks :slight_smile:

···

On Sat, Jul 23, 2016 at 3:54 PM, Daniel Duan <daniel@duan.org> wrote:

This is my impression anyways.

Daniel Duan
Sent from my iPhone

On Jul 23, 2016, at 1:41 PM, Xiaodi Wu via swift-evolution < > swift-evolution@swift.org> wrote:

World's shortest proposal:

*Introduction*

In `String`, the methods `nulTerminatedUTF8` and
`nulTerminatedUTF8CString` have the word "null" misspelled

*Motivation*

There is a typo

*Proposed solution*

Fix the typo

*Impact on existing code*

Emit a fix-it for existing code

*Alternatives considered*

Keep on spelling "nul" without the second "l"

*Acknowledgments*

Thanks to Andrew Trick for confirming that the existing spelling is bizarre

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Dave Abrahams) #4

Xiaodi Wu via swift-evolution <swift-evolution@...> writes:

In `String`, the methods `nulTerminatedUTF8` and
nulTerminatedUTF8CString` have the word "null" misspelled

Whoa. Isn't "Cstring" redundant with "null-terminated?"

···

--
Dave


(Andrew Trick) #5

In the context of character sets, "nul" is the correct name for the 0 value. "null" only makes sense when we are talking about pointer-like references.

Oh, I see: "NUL-terminated" is a thing because "NUL" is the ASCII name. Still a little bizarre looking, though, especially if it's UTF8 rather than ASCII. I am less bothered by it now, thanks :slight_smile:

Yeah. Using the ASCII abbreviation was intentional but after thinking about it for a second I still think it should be renamed. Swift methods are supposed to be spelled out in english. There’s no reason to use an abbreviation here.

-Andy

···

On Jul 23, 2016, at 2:06 PM, Xiaodi Wu via swift-evolution <swift-evolution@swift.org> wrote:
On Sat, Jul 23, 2016 at 3:54 PM, Daniel Duan <daniel@duan.org <mailto:daniel@duan.org>> wrote:

This is my impression anyways.

Daniel Duan
Sent from my iPhone

On Jul 23, 2016, at 1:41 PM, Xiaodi Wu via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

World's shortest proposal:

Introduction

In `String`, the methods `nulTerminatedUTF8` and `nulTerminatedUTF8CString` have the word "null" misspelled

Motivation

There is a typo

Proposed solution

Fix the typo

Impact on existing code

Emit a fix-it for existing code

Alternatives considered

Keep on spelling "nul" without the second "l"

Acknowledgments

Thanks to Andrew Trick for confirming that the existing spelling is bizarre

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Chris Lattner) #6

“NUL” is an abbreviation for “Null Character”. You think that it is a good idea to spell out its full two-word name?

-Chris

···

On Jul 23, 2016, at 2:38 PM, Andrew Trick via swift-evolution <swift-evolution@swift.org> wrote:

On Jul 23, 2016, at 2:06 PM, Xiaodi Wu via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

On Sat, Jul 23, 2016 at 3:54 PM, Daniel Duan <daniel@duan.org <mailto:daniel@duan.org>> wrote:
In the context of character sets, "nul" is the correct name for the 0 value. "null" only makes sense when we are talking about pointer-like references.

Oh, I see: "NUL-terminated" is a thing because "NUL" is the ASCII name. Still a little bizarre looking, though, especially if it's UTF8 rather than ASCII. I am less bothered by it now, thanks :)

Yeah. Using the ASCII abbreviation was intentional but after thinking about it for a second I still think it should be renamed. Swift methods are supposed to be spelled out in english. There’s no reason to use an abbreviation here.


(Andrew Trick) #7

I’ll take the troll bait. “nulTerminatedUTF8" should read “nullTerminatedUTF8” because
1. null-terminated is a common english phrase
2. the acronym is not recognizable lowercase and in the context of the above phrase

Andy

···

On Jul 23, 2016, at 3:16 PM, Chris Lattner <clattner@apple.com> wrote:

On Jul 23, 2016, at 2:38 PM, Andrew Trick via swift-evolution <swift-evolution@swift.org> wrote:

On Jul 23, 2016, at 2:06 PM, Xiaodi Wu via swift-evolution <swift-evolution@swift.org> wrote:

On Sat, Jul 23, 2016 at 3:54 PM, Daniel Duan <daniel@duan.org> wrote:
In the context of character sets, "nul" is the correct name for the 0 value. "null" only makes sense when we are talking about pointer-like references.

Oh, I see: "NUL-terminated" is a thing because "NUL" is the ASCII name. Still a little bizarre looking, though, especially if it's UTF8 rather than ASCII. I am less bothered by it now, thanks :slight_smile:

Yeah. Using the ASCII abbreviation was intentional but after thinking about it for a second I still think it should be renamed. Swift methods are supposed to be spelled out in english. There’s no reason to use an abbreviation here.

“NUL” is an abbreviation for “Null Character”. You think that it is a good idea to spell out its full two-word name?
https://en.wikipedia.org/wiki/Null_character


(Andrew Trick) #8

:slight_smile: Oops sorry, it’s not an acronym, but it never appears lowercase, or in the context of C strings for that matter.
Andy

···

On Jul 23, 2016, at 3:21 PM, Andrew Trick via swift-evolution <swift-evolution@swift.org> wrote:

On Jul 23, 2016, at 3:16 PM, Chris Lattner <clattner@apple.com> wrote:

On Jul 23, 2016, at 2:38 PM, Andrew Trick via swift-evolution <swift-evolution@swift.org> wrote:

On Jul 23, 2016, at 2:06 PM, Xiaodi Wu via swift-evolution <swift-evolution@swift.org> wrote:

On Sat, Jul 23, 2016 at 3:54 PM, Daniel Duan <daniel@duan.org> wrote:
In the context of character sets, "nul" is the correct name for the 0 value. "null" only makes sense when we are talking about pointer-like references.

Oh, I see: "NUL-terminated" is a thing because "NUL" is the ASCII name. Still a little bizarre looking, though, especially if it's UTF8 rather than ASCII. I am less bothered by it now, thanks :slight_smile:

Yeah. Using the ASCII abbreviation was intentional but after thinking about it for a second I still think it should be renamed. Swift methods are supposed to be spelled out in english. There’s no reason to use an abbreviation here.

“NUL” is an abbreviation for “Null Character”. You think that it is a good idea to spell out its full two-word name?
https://en.wikipedia.org/wiki/Null_character

I’ll take the troll bait. “nulTerminatedUTF8" should read “nullTerminatedUTF8” because
1. null-terminated is a common english phrase
2. the acronym is not recognizable lowercase and in the context of the above phrase


#9

And yet the *name* of the character is the “null character
<https://en.wikipedia.org/wiki/Null_character>”, and a string that
terminates in one is called a “null-terminated string
<https://en.wikipedia.org/wiki/Null-terminated_string>”. Those are the
terms of art, and I would not expect an abbreviation in this context.

+1 to the proposed change.

Nevin

···

On Sat, Jul 23, 2016 at 5:06 PM, Xiaodi Wu via swift-evolution < swift-evolution@swift.org> wrote:

On Sat, Jul 23, 2016 at 3:54 PM, Daniel Duan <daniel@duan.org> wrote:

In the context of character sets, "nul" is the correct name for the 0
value. "null" only makes sense when we are talking about pointer-like
references.

Oh, I see: "NUL-terminated" is a thing because "NUL" is the ASCII name.
Still a little bizarre looking, though, especially if it's UTF8 rather than
ASCII. I am less bothered by it now, thanks :slight_smile:

This is my impression anyways.

Daniel Duan
Sent from my iPhone

On Jul 23, 2016, at 1:41 PM, Xiaodi Wu via swift-evolution < >> swift-evolution@swift.org> wrote:

World's shortest proposal:

*Introduction*

In `String`, the methods `nulTerminatedUTF8` and
`nulTerminatedUTF8CString` have the word "null" misspelled

*Motivation*

There is a typo

*Proposed solution*

Fix the typo

*Impact on existing code*

Emit a fix-it for existing code

*Alternatives considered*

Keep on spelling "nul" without the second "l"

*Acknowledgments*

Thanks to Andrew Trick for confirming that the existing spelling is
bizarre

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Xiaodi Wu) #10

In the context of character sets, "nul" is the correct name for the 0
value. "null" only makes sense when we are talking about pointer-like
references.

Oh, I see: "NUL-terminated" is a thing because "NUL" is the ASCII name.
Still a little bizarre looking, though, especially if it's UTF8 rather than
ASCII. I am less bothered by it now, thanks :slight_smile:

Yeah. Using the ASCII abbreviation was intentional but after thinking
about it for a second I still think it should be renamed. Swift methods are
supposed to be spelled out in english. There’s no reason to use an
abbreviation here.

“NUL” is an abbreviation for “Null Character”. You think that it is a
good idea to spell out its full two-word name?
https://en.wikipedia.org/wiki/Null_character

I’ll take the troll bait. “nulTerminatedUTF8" should read
“nullTerminatedUTF8” because
1. null-terminated is a common english phrase
2. the acronym is not recognizable lowercase and in the context of the
above phrase

:slight_smile: Oops sorry, it’s not an acronym, but it never appears lowercase, or in
the context of C strings for that matter.

I'm not entirely confident it was a great idea to raise this issue, but now
that we're having the discussion: NUL is of a kind with control codes BS,
CAN, CR, HT, LF, SP, DEL, the corresponding names being null, backspace,
cancel, carriage return, [horizontal] tab, line feed, space, and delete.
For most of these (with the exception of CR and LF, both because the full
name is long and the symbol is more widely used), I'd imagine that what
would be preferred in a variable name would be the written-out form.

Andy

···

On Sat, Jul 23, 2016 at 5:29 PM, Andrew Trick via swift-evolution < swift-evolution@swift.org> wrote:

On Jul 23, 2016, at 3:21 PM, Andrew Trick via swift-evolution < > swift-evolution@swift.org> wrote:
On Jul 23, 2016, at 3:16 PM, Chris Lattner <clattner@apple.com> wrote:
On Jul 23, 2016, at 2:38 PM, Andrew Trick via swift-evolution < > swift-evolution@swift.org> wrote:
On Jul 23, 2016, at 2:06 PM, Xiaodi Wu via swift-evolution < > swift-evolution@swift.org> wrote:
On Sat, Jul 23, 2016 at 3:54 PM, Daniel Duan <daniel@duan.org> wrote:

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Félix Cloutier) #11

So I can see in hindsight that perhaps people meant "NUL-terminated string" the whole time, but "NUL-terminated string" has 19,700 results on Google, whereas "null-terminated string" has 192,000.

I have a funny anecdote to share. I got really upset on reddit one day <https://xkcd.com/386/> that someone said that some trojan was a "virus". That's not right! Trojans are not viruses! And then someone came along and asked, "what type of software would you use to remove a trojan?" And the answer to that, of course, is an anti-virus.

I can come up with a number of other instances where people use technically incorrect names that are just so powerfully ingrained that it's not even worth it to fight back. Like JPEG vs JFIF.

Point being, while I have lots of respect for standards, if what you want is consensus, siding with the 90% is a better idea.

Félix

···

Le 23 juil. 2016 à 15:21:48, Andrew Trick via swift-evolution <swift-evolution@swift.org> a écrit :

On Jul 23, 2016, at 3:16 PM, Chris Lattner <clattner@apple.com> wrote:

On Jul 23, 2016, at 2:38 PM, Andrew Trick via swift-evolution <swift-evolution@swift.org> wrote:

On Jul 23, 2016, at 2:06 PM, Xiaodi Wu via swift-evolution <swift-evolution@swift.org> wrote:

On Sat, Jul 23, 2016 at 3:54 PM, Daniel Duan <daniel@duan.org> wrote:
In the context of character sets, "nul" is the correct name for the 0 value. "null" only makes sense when we are talking about pointer-like references.

Oh, I see: "NUL-terminated" is a thing because "NUL" is the ASCII name. Still a little bizarre looking, though, especially if it's UTF8 rather than ASCII. I am less bothered by it now, thanks :slight_smile:

Yeah. Using the ASCII abbreviation was intentional but after thinking about it for a second I still think it should be renamed. Swift methods are supposed to be spelled out in english. There’s no reason to use an abbreviation here.

“NUL” is an abbreviation for “Null Character”. You think that it is a good idea to spell out its full two-word name?
https://en.wikipedia.org/wiki/Null_character

I’ll take the troll bait. “nulTerminatedUTF8" should read “nullTerminatedUTF8” because
1. null-terminated is a common english phrase
2. the acronym is not recognizable lowercase and in the context of the above phrase

Andy

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution


(Erica Sadun) #12

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)

-- E

···

On Jul 24, 2016, at 3:45 PM, Dave Abrahams via swift-evolution <swift-evolution@swift.org> wrote:

Xiaodi Wu via swift-evolution <swift-evolution@...> writes:

In `String`, the methods `nulTerminatedUTF8` and
nulTerminatedUTF8CString` have the word "null" misspelled

Whoa. Isn't "Cstring" redundant with "null-terminated?"


(Saagar Jha) #13

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.

Saagar Jha

···

On Jul 24, 2016, at 15:58, Xiaodi Wu via swift-evolution <swift-evolution@swift.org> wrote:

On Sun, Jul 24, 2016 at 5:34 PM, Erica Sadun via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

> On Jul 24, 2016, at 3:45 PM, Dave Abrahams via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>
> Xiaodi Wu via swift-evolution <swift-evolution@...> 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@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution


(Saagar Jha) #14

Ahh…I agree in that case; something like `utf8Array` might be a better choice.
Saagar Jha

···

On Jul 24, 2016, at 16:44, Xiaodi Wu <xiaodi.wu@gmail.com> wrote:

On Sun, Jul 24, 2016 at 6:42 PM, Saagar Jha <saagarjha28@gmail.com <mailto:saagarjha28@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@swift.org <mailto:swift-evolution@swift.org>> wrote:

On Sun, Jul 24, 2016 at 5:34 PM, Erica Sadun via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

> On Jul 24, 2016, at 3:45 PM, Dave Abrahams via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:
>
> Xiaodi Wu via swift-evolution <swift-evolution@...> 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@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution


(Dave Abrahams) #15

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.

···

on Sun Jul 24 2016, Saagar Jha <saagarjha28-AT-gmail.com> wrote:

Saagar Jha

On Jul 24, 2016, at 16:44, Xiaodi Wu <xiaodi.wu@gmail.com> wrote:

On Sun, Jul 24, 2016 at 6:42 PM, Saagar Jha <saagarjha28@gmail.com <mailto:saagarjha28@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@swift.org <mailto:swift-evolution@swift.org>> >>> wrote:

On Sun, Jul 24, 2016 at 5:34 PM, Erica Sadun via swift-evolution >>> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> >>> wrote:

> On Jul 24, 2016, at 3:45 PM, Dave Abrahams via swift-evolution >>> > <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> >>> > wrote:
>
> Xiaodi Wu via swift-evolution <swift-evolution@...> 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@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution


(Xiaodi Wu) #16

>
> Xiaodi Wu via swift-evolution <swift-evolution@...> 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

···

On Sun, Jul 24, 2016 at 5:34 PM, Erica Sadun via swift-evolution < swift-evolution@swift.org> wrote:

> On Jul 24, 2016, at 3:45 PM, Dave Abrahams via swift-evolution < > swift-evolution@swift.org> wrote:

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Xiaodi Wu) #17

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 Sun, Jul 24, 2016 at 6:42 PM, Saagar Jha <saagarjha28@gmail.com> wrote:

On Jul 24, 2016, at 15:58, Xiaodi Wu via swift-evolution < > swift-evolution@swift.org> wrote:

On Sun, Jul 24, 2016 at 5:34 PM, Erica Sadun via swift-evolution < > swift-evolution@swift.org> wrote:

> On Jul 24, 2016, at 3:45 PM, Dave Abrahams via swift-evolution < >> swift-evolution@swift.org> wrote:
>
> Xiaodi Wu via swift-evolution <swift-evolution@...> 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@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


#18

I think the hypothetical alternative would be `nullTerminatedCString` for
one and `nullTerminatedUTF8` for the other.

Nevin

···

On Sun, Jul 24, 2016 at 6:34 PM, Erica Sadun via swift-evolution < swift-evolution@swift.org> wrote:

> On Jul 24, 2016, at 3:45 PM, Dave Abrahams via swift-evolution < > swift-evolution@swift.org> wrote:
>
> Xiaodi Wu via swift-evolution <swift-evolution@...> 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)

-- E

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Xiaodi Wu) #19

> 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.

···

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

on Sun Jul 24 2016, Saagar Jha <saagarjha28-AT-gmail.com> wrote:

> Saagar Jha
>
>> On Jul 24, 2016, at 16:44, Xiaodi Wu <xiaodi.wu@gmail.com> wrote:
>>
>> On Sun, Jul 24, 2016 at 6:42 PM, Saagar Jha <saagarjha28@gmail.com > <mailto:saagarjha28@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@swift.org <mailto:swift-evolution@swift.org>> > >>> wrote:
>>>
>>> On Sun, Jul 24, 2016 at 5:34 PM, Erica Sadun via swift-evolution > >>> <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> > >>> wrote:
>>>
>>> > On Jul 24, 2016, at 3:45 PM, Dave Abrahams via swift-evolution > >>> > <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> > >>> > wrote:
>>> >
>>> > Xiaodi Wu via swift-evolution <swift-evolution@...> 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@swift.org <mailto:swift-evolution@swift.org>
>>> https://lists.swift.org/mailman/listinfo/swift-evolution <
https://lists.swift.org/mailman/listinfo/swift-evolution>
>>>
>>> _______________________________________________
>>> swift-evolution mailing list
>>> swift-evolution@swift.org <mailto:swift-evolution@swift.org>
>>> https://lists.swift.org/mailman/listinfo/swift-evolution <
https://lists.swift.org/mailman/listinfo/swift-evolution>
>>


(Boris Wang) #20

Good point,
Redundant may be a dangerous indication for unsuitable classification in
program design.

By the name,I will think there has non-null terminated CString.
But strings always terminated by null in language C.