3 ms·
Suppose you have MyVariable and my_variable in your code. Which is worse: them being the same variable or different variables? It's a pretty bad code smell
by bryanlarsen 12y ago
Suppose you have MyVariable and my_variable in your code. Which is worse: them being the same variable or different variables? It's a pretty bad code smell either way.
In my opinion it should be an error or at least a warning.
I'm not a big fan of nim's behaviour, but I don't think it's any worse than what other languages do.
- wtetzner 12y agoYeah, I think it would make more sense to treat them as the same, but throw an error if they are spelled differently.
- krupan 12y ago"Which is worse: them being the same variable or different variables?" Them being the same is worse. I agree that both are pretty darn bad, but it's also pretty clear to me which is worse.
- tomp 12y ago> Suppose you have MyVariable and my_variable in your code. Which is worse: them being the same variable or different variables? That's the same as saying "`a` and `A` should be the same variable", i.e. complete case insensitivity. > It's a pretty bad code smell either way. Very much so. We shouldn't encourage it.
- dragonwriter 12y ago> Suppose you have MyVariable and my_variable in your code. Which is worse: them being the same variable or different variables? Having them be the same, by far. Having names with certain similarity be prohibited in the same scope is a bit excessively controlling but sensible. Allowing them but treating them as equivalent is just plain bad. If I named them differently then either: (1) I made a mistake, or (2) I intended them to be different.
- reddit_clone 12y agoHuh? This is terrible. I use same names with different styles to denote scope. I will be hosed then.