Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec: array constants #6388

Closed
gopherbot opened this issue Sep 14, 2013 · 1 comment
Closed

spec: array constants #6388

gopherbot opened this issue Sep 14, 2013 · 1 comment
Labels
FrozenDueToAge LanguageChange Suggested changes to the Go language

Comments

@gopherbot
Copy link
Contributor

by RickySeltzer:

The syntax for initializing arrays of byte arrays is excessively restrictive and very
inelegant and inconvenient.  Both of these ought to compile and do the obvious thing.

See Also issue #6386: http://code.google.com/p/go/issues/detail\?id\=6386

There are TWO problems.
 I) Arrays of constants can not be declared const.
 II) The syntax requires peppering the source with REDUNDANT redeclarations of '[]byte' before each word.

    const epigram [][]byte = [][]byte {
    []byte("He"), []byte("who"), []byte("laughs"),
    []byte("last"), []byte("laughs"), []byte("best."),
    }

    var epigram2 [][]byte = [][]byte {
    "He", "who", "laughs",
    "last", "laughs", "best.",
    }

1. What is a short input program that triggers the error?
http://play.golang.org/p/g7A-bNLV7L

2. What is the full compiler output?
prog.go:13: cannot use "He" (type string) as type []byte in array element
prog.go:13: cannot use "who" (type string) as type []byte in array element
prog.go:13: cannot use "laughs" (type string) as type []byte in array element
prog.go:14: cannot use "last" (type string) as type []byte in array element
prog.go:14: cannot use "laughs" (type string) as type []byte in array element
prog.go:14: cannot use "best." (type string) as type []byte in array element
prog.go:15: const initializer <T> literal is not a constant

3. What version of the compiler are you using?  (Run it with the -V flag.)
any
@robpike
Copy link
Contributor

robpike commented Sep 14, 2013

Comment 1:

Labels changed: added priority-someday, languagechange, removed priority-triage, go1.2maybe.

Status changed to Duplicate.

Merged into issue #6386.

@gopherbot gopherbot added duplicate LanguageChange Suggested changes to the Go language labels Sep 14, 2013
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge LanguageChange Suggested changes to the Go language
Projects
None yet
Development

No branches or pull requests

2 participants