9 ms·
Does Nim still allow indifferent `fooBar()` and `foo_bar()` to access the same function call ? It makes grep-powered refactoring unnecessarily hard.
by zimbatm 12y ago
Does Nim still allow indifferent `fooBar()` and `foo_bar()` to access the same function call ? It makes grep-powered refactoring unnecessarily hard.
- def- 12y agoYes, Nim still uses partial case insensitivity: http://nim-lang.org/manual.html#identifier-equality http://nim-lang.org/manual.html#identifier-equality I agree that it's a problem with grep, there's a nimgrep tool that you could use instead, but I don't. The nice part about it is that you can use a consitent naming convention even when using external libraries. My idea to solve the problems this causes without removing it would be a gofmt like tool as described here: https://github.com/Araq/Nim/wiki/GSoC-2015-Ideas#nimfmt-automatically-format-nim-code https://github.com/Araq/Nim/wiki/GSoC-2015-Ideas#nimfmt-auto...
- gtaylor 12y agoIs there any way to disable this behavior? I've been curious about Nim, but this makes me cringe pretty hard. I get the intention, but this is exactly the kind of magic that I dislike.
- krupan 12y agoI haven't used go or gofmt, but I don't quite understand the appeal. gofmt doesn't go both ways, right? You can't write go in one style and then gofmt it to share, and then un-gofmt it back to your preferred style, right? Seems like it would still be easiest to just get comfortable writing and reading in the style gofmt produces. At that point, gofmt is just for catching little mistakes, which, maybe the compiler could just do for you. I see python and nim's significant whitespace as a step in that direction. Why not have the compiler/interpreter enforce a certain number of spaces for indentation? Why not enforce a certain naming style?
- kej 12y ago>Seems like it would still be easiest to just get comfortable writing and reading in the style gofmt produces. That's the entire point of gofmt. Like many of Go's design choices, it's there to subtly (or not so subtly) encourage doing things in one consistent way.
- msie 12y agoOh god, this is so horrible. I've never seen this in the many languages I've used and consider all the programmers happily using those languages without this "feature". Please kill this feature now while the language is still relatively young.
- Scramblejams 12y agoYour comment made me wonder if this feature was conceived as a red herring just to keep people from going on about significant whitespace. :-) If I ever design a language I might have to remember that.
- jessaustin 12y agoHa! Great idea. Significant whitespace is a good thing. "partial case insensitivity"? KIWF! Or at least let it be overridden via configuration flags.
- wtetzner 12y ago> The nice part about it is that you can use a consitent naming convention even when using external libraries. I think a slightly nicer (in the sense that it would catch more typos) way to do it might be to specify the naming convention at the top of the source file, and have the compiler enforce that naming convention within the file. Maybe also have a way to set it in the build system, so it could enforce it for the whole project. That way your project is consistent, but the libraries you rely on don't have to match your conventions.
- Retra 12y agoI was about to say the same thing (about enforcing the convention directly.) But there's a problem. Let's say I write a function called `HTTPHeaderScan()`. Someone else might have used `HttpHeaderScan()`. Or worse: `HtTpHeAdErScAn()`. How do you enforce one over the other? If you said "everthing must be CamelCase," how do you know that the name is wrong?
- rat87 12y agoAssuming you have a consistent naming scheme for your language I'd assume this would be mostly used to call libraries written in other languages
- krupan 12y agoLooks like it's still there in the manual: http://nim-lang.org/0.11.0/manual.html#lexical-analysis-identifier-equality http://nim-lang.org/0.11.0/manual.html#lexical-analysis-iden... This just killed my excitement for this language. That's really surprising to me that they would choose to enforce indentation Python-style, but would then allow this kind ambiguity in naming. grep and emacs isearch-forward are such great tools for quick code searching and this will break them. I guess text search (and replace) tools could grow nim-mode options, maybe. I don't know, can someone convince me this is a good idea?
- gtaylor 12y ago> I don't know, can someone convince me this is a good idea? That would be a pretty hard sell. Any convenience argument falls flat to me.
- bryanlarsen 12y agoSuppose 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.
- aikah 12y agoThis feature makes very little sense to me. What's the justification for this?
- progman 12y agoDeveloper convenience. Some people like Hungarian notation, some like underscores. I consider it quite convenient as well. Probably there is a need for a tool for source code normalization so that everyone can choose his favorite notation in the whole Nim ecosystem.
- duaneb 12y agoI wouldn't consider the loss of identifier recognition a "convenience". This would be a major concern for my adopting the language. You also have to read others' code, as well...
- federico3 12y agoSafety! Having "my_cat" and "myCat" as different variables in the same space sometimes ends up with using the wrong variable, especially when using tab completion. The feature is not meant to encourage developers to use "my_cat" and "myCat" randomly within the same file.
- msie 12y agoI don't like the idea of a language encouraging sloppy coding.
- federico3 12y agoThis is not different than having foo_bar and foo_Bar as two different variables.
- dragonwriter 12y agoWell, yes, it is. And its worse, especially when the variables aren't "foo_bar" and "foo_Bar", but, say, "cycle_often" and "cycle_of_ten".
- gcao 12y agoWhy not just recommend one way of naming things and do it in all standard APIs? If someone obviates in his custom library, that's his problem. I think below are pretty much a standard in many languages now. THIS_IS_A_CONSTANT SomeClass someVariable someMethod()