4 ms·
This is exactly what Nim does. If you try to define both my_var and myVar it will error out. The benefit is to avoid confusing variables or procs named my_var,
by nimmer 4y ago
This is exactly what Nim does. If you try to define both my_var and myVar it will error out.
The benefit is to avoid confusing variables or procs named my_var, myVar and myvar.
- Symmetry 4y agoIf you define them both yes, but you're still free to use them both. var my_var = 1 myVar += 1 echo(my_var) Will happily compile and give you 2. I'd prefer an error in that case because while I'm not liable to make that mistake but I could easily mistype long_variable_name as long_variablename without noticing and then cause myself problems when I try to grep.
- def- 4y agonim --styleCheck:error c x This enforces the same capitalization style in your code: x.nim(1, 5) Error: 'my_var' should be: 'myVar'
- nimmer 4y agoYou can use --styleCheck:usages or a linter to ensure that the style is uniform. You cane enable styleCheck:usages by default in the compiler. Also, most editors do variable/proc autocompletion. Also you can use nimgrep if have to search across projects written by different people.
- arc776 4y agoSearching has never been a problem for me in years of using Nim but there is `nimgrep` bundled for style insensitive search. Also I'm no RE wiz, but seems like RE might help if it came down it. Just to stress myself as an anecdote though, I have years in the language and it hasn't come up yet for me, and I've never needed to use `nimgrep`.