FAQ
The dual usage of character and rune in the specification to describe
Unicode code points is confusing. I'd like to propose the following change
to the specification document. Starting under the "Source code
representation" section, all occurrences of "character" should be replaced
with "rune" except when preceded by "Unicode".

The significance of the "Source code representation" section is that it
defines a rune in the context of the language.
For simplicity, this document will use the unqualified term *character*to refer to a Unicode code point in the source text.
For simplicity, this document will use the unqualified term *rune* to
refer to a Unicode code point in the source text.

--

Search Discussions

  • Jason Travis at Dec 8, 2012 at 7:52 pm
    A specific example where the dual usage has caused confusion is in the
    first paragraph of the Constants section:
    There are boolean constants, *rune* constants, integer constants,
    floating-point constants, complex constants, and string constants. *
    Character*, integer, floating-point, and complex constants are
    collectively called numeric constants.
    There are no character constants.
    http://golang.org/ref/spec#Constants
    On Saturday, December 8, 2012 10:06:47 AM UTC-7, Jason Travis wrote:

    The dual usage of character and rune in the specification to describe
    Unicode code points is confusing. I'd like to propose the following change
    to the specification document. Starting under the "Source code
    representation" section, all occurrences of "character" should be replaced
    with "rune" except when preceded by "Unicode".

    The significance of the "Source code representation" section is that it
    defines a rune in the context of the language.
    For simplicity, this document will use the unqualified term *character*to refer to a Unicode code point in the source text.
    For simplicity, this document will use the unqualified term *rune* to
    refer to a Unicode code point in the source text.
    --
  • Kevin Gillette at Dec 9, 2012 at 5:10 am

    On Saturday, December 8, 2012 12:52:55 PM UTC-7, Jason Travis wrote:
    There are no character constants.
    Depending on the context, sure there are/were (just apparently not distinct
    from 'rune literals').

    http://play.golang.org/p/P51mgAvi1Z

    I think some of the confusion will come from the untyped nature of rune
    literals, since rune is a type, but char or character is not (in Go, at
    least). As with C, anything in single quotes is interpreted to be an
    integer of some value (if valid), and since rune literals are untyped
    integers, they can be assigned to any integer type (hence being able to
    assign a unicode codepoint sequence [in the range 0-255] to a byte variable
    without conversion, despite the apparent semantic absurdity).

    Here, 'character constant' (or more precisely, 'character literal'), would
    not have the type ambiguity that 'rune literal' would, and may therefore be
    less absurd. After all, runes are characters in the computational
    linguistic sense, and if you're storing a single-quoted constant value into
    a byte, you're certainly treating that byte value as non-binary data (since
    you're giving it a glyph), so you're artificially imposing the 'character'
    terminology on yourself again.

    --

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 8, '12 at 5:06p
activeDec 9, '12 at 5:10a
posts3
users2
websitegolang.org

2 users in discussion

Jason Travis: 2 posts Kevin Gillette: 1 post

People

Translate

site design / logo © 2021 Grokbase