-
Notifications
You must be signed in to change notification settings - Fork 689
go: prune 'exported' fields and constants; improve readability #97
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
Conversation
|
"Readability" is somewhat subjective. |
|
Thanks for your reviewing. The PR has been rejected but I still want to explain the refactoring a little bit more here. The 'unexport' refactoring is that, the capitalized fields could be only used for exported struct. Actually, most of the fields in GopherLua should be unexported because they're internal struct. This massive refactoring mainly lowercase them. And all unexported struct except for two, constValueExpr and lValue…(sorry I forgot the name). It's true that something can be confusing: I'm sorry for confusing you. Anyway I hope these trivial minor changes could be useful for your consideration. Happy new year! (From my hometown) |
|
Thanks for your detailed explanations. The reason that I have used capitalized fileds for unexported structs, these fields are exported for structs. For example: we have an unexported struct like the following: type user struct {
name string
age int
somePrivateValue int
}This struct is unexported for now . Consider the case that we want to export this struct for some reason in the future. type User struct {
name string
age int
somePrivateValue int
}It's pointless. type User struct {
Name string
Age int
somePrivateValue int
}So, I am using capitalized fields for unexported structs while taking that into account. This is a bad idea? |
|
No, it isn't. It is good. But it's time to come to some details that the PR has three kind of change here about 'unexport':
Let's take a look at 2&3. To unexport fields in unexported structtype user struct {
Name string
Age int
somePrivateValue int
}This is the most thing in the PR. Yes, your idea is definitely okay. And further more, to change or not, actually, will never affect the 'surface' of package. I think I got your point of keeping this. I will revert them in my repo. To unexport fields as neither exported struct nor exported interfaceExcactly, there is only one in this kind, but also is the worst one. type CompileError struct { // {{{
Context *funcContext
Line int
Message string
}Well, it could be very confusing programmers in at least these two reason:
Obviously, there are two ways to improve it:
I prefer the first one. the second one could lead to more massive refactoring, and 'pull back' the line between external and internal. The most important thing is that a struct for external error report should not export such internal mechanism. Got any thoughts on this one? I'm all ears. |
Changes proposed in this pull request: