ref: move string literals to constants#4477
Conversation
|
What's the goal here? Is the idea that this improves readability? |
leongross
left a comment
There was a problem hiding this comment.
imo removing the string constants has several benefits. First, it removes the possibility for typos and inconsistencies. A lot of these strings are used in several places with the same value. If the names are descriptive enough I think it eases the development workflow and prohibits typos, also it makes the relations clearer (i.e. BinFormat{...}) lists all the available BinFormats, so no need to look up all the possible definitions in the code. I agree, putting this into an enum is also a good idea. But since many of these options are passed literally to llvm and other build steps (I think) it makes sense to keep this as a string.
True, but does that actually happen? Did you find any bugs with these issues? There are some cases where I think constants could be helpful, but those are in fact enums. For example for GC or scheduler types. They could be used like this, for example: type GCType string
const (
GCConservative GCType = "conservative"
GCPrecise GCType = "precise"
// etc
}(Also, I think you forgot to add some new files in this PR). |
Signed-off-by: leongross <leon.gross@9elements.com>
d266a4c to
2620e21
Compare
I agree making changing the const strings to enums is a good idea. But I am not sure I fully understand which cases you see as useful and which not. |
No description provided.