4 ms·
> Constant names can now start with non-ASCII capital letters. I am not sure how useful this is Very? If you want to code in non-Latin languages. Also, π = 3.
by mmahemoff 8y ago
> Constant names can now start with non-ASCII capital letters. I am not sure how useful this is
Very? If you want to code in non-Latin languages.
Also, π = 3.14159
- ascar 8y agoI'm not sure about this being good for coding in non-latin. It might actually encourage behavior to mistreat ruby constants as regular variables. IIRC constants are not really constant, but only visual help for reading code and ruby just issues a warning on reassignment and these warnings are not shown by default. I can totally imagine new devs just trying out non-ascii variables, see it not crashing and then actually writing all their code using constants.
- matt4077 8y agoI don't quite understand how this change makes the (somewhat remote) misunderstanding you describe any more likely than it previously was for people using ASCII only. I also just tried and was duly warned upon reassignment, a setting I don't remember changing.
- jwdunne 8y agoRe-assignment warns by default. I tried it, exploring to see what was possible. It indeed worked but threw a warning. I hadn't changed configuration.
- dragonwriter 8y ago> I can totally imagine new devs just trying out non-ascii variables, see it not crashing and then actually writing all their code using constants. Ruby already supported non-ascii identifiers for variables; 2.6 added support for non-ascii first characters of constants, which must still be capital letters, as had always distinguished constants from variables. It doesn't make anything non-ascii a constant, it just makes constants consistent with other identifiers in terms of non-ascii support, while preserving the “initial capital means constant" rule. And, as sibling comments note, reassigning a constant produces a warning, so devs making a mistake and using constants for variables (regardless of ascii-ness) will quickly be informed of their error.
- ascar 8y agoI wasn't aware of non-ascii variables. I was thinking about UTF support for Japanese characters, when I read the change. There is no concept of lowercase/uppercase. 日本語 is this a constant or variable?
- dragonwriter 8y agoSince constants are the exception, and used to require an ASCII capital but now can start with ant capital, an identifiers starting with a Unicode character in a script that doesn't have upper/lower case distinction is a variable, not a constant.
- sixstringtheory 8y agoLooks like an ‘n’ at first glance. Just as easy to type “pi”.