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

proposal: spec: export uncased identifiers like 日本語 #16033

Closed
robpike opened this issue Jun 10, 2016 · 2 comments
Closed

proposal: spec: export uncased identifiers like 日本語 #16033

robpike opened this issue Jun 10, 2016 · 2 comments
Labels
FrozenDueToAge LanguageChange Suggested changes to the Go language Proposal v2 An incompatible library change
Milestone

Comments

@robpike
Copy link
Contributor

robpike commented Jun 10, 2016

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.

@robpike robpike added LanguageChange Suggested changes to the Go language v2 An incompatible library change labels Jun 10, 2016
@SamWhited
Copy link
Member

SamWhited commented Jun 10, 2016

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.

I started work (and then abandoned) a draft RFC for a PRECIS profile for programing language identifiers a while back. Specifically this used the NFC canonicalization rule for combining characters and a width mapping rule to ensure that full-width and half-width characters were mapped to their decomposition mappings (on some machines a keystroke may output a full-width character while on another machine the same keystroke outputs the half-width version; this presumably would be very confusing for users in locales that use full-width characters heavily such as many East Asian languages).

I'd love to see a PRECIS profile used for all Go identifiers in the future, and would be happy to pick back up the RFC work and help the community standardize on a set of rules.

EDIT: Related Rust issue: rust-lang/rust#28979

@quentinmit quentinmit added this to the Proposal milestone Jul 29, 2016
@rsc rsc modified the milestones: Unplanned, Proposal Nov 21, 2016
@rsc rsc changed the title proposal: adjustments to identifiers and export rules proposal: spec: export uncased identifiers like 日本語 Jun 16, 2017
@rsc
Copy link
Contributor

rsc commented Jun 17, 2017

Duplicate of #5763, which has richer discussion. Closing this one.

@rsc rsc closed this as completed Jun 17, 2017
@golang golang locked and limited conversation to collaborators Jun 17, 2018
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 Proposal v2 An incompatible library change
Projects
None yet
Development

No branches or pull requests

5 participants