4 ms·
This doesn't make any sense. When I make a mistake in case, Rust just doesn't let me compile.
by iopq 12y ago
This doesn't make any sense. When I make a mistake in case, Rust just doesn't let me compile.
- rbehrends 12y agoYou get this problem when you have two identifiers (variables, functions, constants, etc.) that differ only in case and have the same type signature. Depending on whether you use one or the other form, you may get completely different behavior.
- iopq 12y agoThe convention is that upper case is types, lower case is variables. So you'd have to try hard to make that mistake.
- rbehrends 12y agoThat has nothing to do with types vs. variables. Try having a variable signon and a variable signOn. Or two functions with the same type signature, one called signon() and one signOn() (for example, imported from two different modules).
- kibwen 12y agoBy default, the Rust compiler warns you when you use uppercase characters in variable and function identifiers. The community overwhelmingly adheres to this style. Rust is also extremely strongly-typed, so not only would you have to be willfully disabling the style warnings, you would have to have to manage to give them the same types, and furthermore given the nature of Rust code it's rather possible that you'll still get a compilation error due to using a variable in a way that it didn't expect. You also can't "accidentally" introduce new variables in Rust, as you can in Python via typos.
- rbehrends 12y agoYes, enforcing case strictly via style guidelines that prevent mixing of upper- and lowercase is another way of avoiding that problem (underscores can still trip you up in a similar fashion, of course, e.g. signon vs. sign_on). I'm still not sure how the discussion got sidetracked into discussing Rust, though.
- Dewie3 12y ago> I'm still not sure how the discussion got sidetracked into discussing Rust, though. Yes, let's generalize - reading the blog and the comments, this "case sensitivity ruins productivity"-problem seems to only be a problem in scripting languages.
- iopq 12y agoYou'd have to declare both of them in the current module. That's why I don't do glob imports. I would see use foo::signon; use bar::signOn; clearly, if I have to import this in my own file I should be VERY careful about those two functions or rather, I'd import from foo, but I'd use the namespaced version from bar so `signon` would be `foo::signon`, but `bar::signOn` would be written out fully to avoid this kind of clash
- rbehrends 12y agoI'm really not sure what the point of referencing Rust is. This was about programming languages in general, and the post I was referring to was about C#. Also, importing is an example, another example would be accidentally declaring a second variable in the same module (should not happen, but people make errors), or a number of other situations where two identifiers that are identical except for case end up in the same scope.
- iopq 12y agoI'm referencing Rust because I'm working on a Rust project right now. I don't even know C#. Here's how you declare a binding: let signOn; let signon; I seriously hope you don't declare both of these in the same scope