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

Recommend to keep the visibility of the top-level identifiers #3

Open
hjianhao opened this issue Jun 1, 2016 · 3 comments
Open

Recommend to keep the visibility of the top-level identifiers #3

hjianhao opened this issue Jun 1, 2016 · 3 comments

Comments

@hjianhao
Copy link

hjianhao commented Jun 1, 2016

If the new package starts with ".", All top-level identifiers will have prefixes to prevent conflicts, and their uses will also be updated.

for example, I use ".int" package name to generalize queue, the "New" function will rewrite to "intNew", this changed the visibility of the template function "New". If I used ".Int", it may changed the visibility of those identifiers started with lower case character. So I recommend to keep the visibility of the top-level Identifiers.

@taylorchu
Copy link
Owner

I think this issue only applies to .result package target.

Do you have a suggestion to keep top-level identifiers to be exported while we still have prefixing?

For me, it is nice to have all top-level identifiers unexported:

  1. prefixed identifier name is ugly for exported API.
  2. Although it was exported, it might not be needed to be exported after rewrite under the new package.

If it is needed, I often create aliases in the current package in another file like:

func New() *IntQueue {
   return intNew()
}

@hjianhao
Copy link
Author

hjianhao commented Jun 2, 2016

I think the simple rule is : if top level identifier start with lower case character, then Chang the prefix first letter to Lower case, vice versa.

@taylorchu
Copy link
Owner

prefix in general should be all lowercase yyy. Could you explain more about your idea if the generic package has uppercase top-level identifiers, like Xxx? The current behavior is yyyXxx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants