Question on rune literals in golang spec

132 views
Skip to first unread message

spe...@spencerbrown.org

unread,
Jan 15, 2017, 7:55:27 PM1/15/17
to golang-nuts
"If the source code represents a character as two code points, such as a combining form involving an accent and a letter, the result will be an error if placed in a rune literal (it is not a single code point), and will appear as two code points if placed in a string literal."

Am I reading this wrong, or is the parenthesized phrase redundant? How could the source code represent a character as two code points in a rune, yet it is a single code point?

Spencer

Rob Pike

unread,
Jan 15, 2017, 8:09:41 PM1/15/17
to spe...@spencerbrown.org, golang-nuts
It cannot; that's why it's an error if attempted.

The parenthesized phrase is redundant but explanatory.

-rob



--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

spe...@spencerbrown.org

unread,
Jan 16, 2017, 10:03:29 AM1/16/17
to golang-nuts, spe...@spencerbrown.org

It cannot; that's why it's an error if attempted.

The parenthesized phrase is redundant but explanatory.

Thank you, Commander Rob :).

As a newbie I was suspicious that the phrase "(it is not a single code point)" had some deep implication that I did not understand.

 Might I suggest directly spelling out the implications on a case by case basis, because I now understand what this is really trying to say is that Go does not combine characters in string and rune literals. The suggestion is to replace the paragraph with:

"The source code may contain two code points that represent a character, such as a combining form involving an accent and a letter. If placed in a string literal, this will appear as two code points. If placed in a rune literal, this will result in an error, because it is not a single code point."
Reply all
Reply to author
Forward
0 new messages