proposal: spec: export uncased identifiers like 日本語 #16033
Labels
FrozenDueToAge
LanguageChange
Suggested changes to the Go language
Proposal
v2
An incompatible library change
Milestone
The current export rule says, in brief, a variable is exported if its first character is an upper-case letter. This means that there is no way to have an exported identifier that is a word in a non-alphabetic language such as Japanese or Chinese.
I propose we specify the rule the other way around:
A variable is not exported if its first character is a lower-case letter or underscore.
This makes that a name like 日本語 would be exported; to avoid export call it _日本語.
The change is pretty minor and will have almost no effect on existing programs I know of, but will cause programs using Han identifiers to export previously unexported identifiers. I don't know of any, but the point that it is impossible to have an exported non-alphabetic identifier has been made many times, always (to me at least) by people who speak alphabetic languages.
Still, this would fix that problem simply, if it needs fixing.
Moved to #20706:
On a related note, some writing systems - Devanagari is one (see #5167) require combining characters. The current identifier rules forbid combining characters; perhaps that should be relaxed, although that will require a canonicalization rule for combining characters. Unicode does have a definition for identifiers (http://unicode.org/reports/tr31/); perhaps Go should use it. Note that the addition of combining characters, allied with the export proposal above, would make it possible to export Devanagari identifiers.The text was updated successfully, but these errors were encountered: