我应该避免在变量名中使用unicode字符吗?
C#语言规范说我们可以在说明符中使用Unicode字符(类和变量名等)
The C# language specification says we can use unicode characters in specifiers (class and variable names, etc.)
我在代码中做了很长的路要走.由于我住在巴西,所以其中包含很多带重音符号的字符,并带有诸如rotação
,ângulo
,máximo
等的变量名.
I went a long way doing this in my code. Since I live in Brazil, this includes lots of accented characters, with variable names such as rotação
, ângulo
, máximo
, etc.
每当一个经验更丰富"的开发人员都意识到这一点时,我强烈建议您避免使用它,并将一切变回原本的状态,否则很多小猫会死掉.
Everytime a more "experienced" developers catches this, I am STRONGLY advised to avoid it and change everything back, otherwise a lot of kittens will die.
我走了很长一段路撤消,但是今天我发现在很早以前编写的方法中,仍有一些仍带有重音符号的变量,到目前为止,还没有小猫死(至少不是因为那个).
I went then a quite long way undoing it, but today I found some variables still named with accents, in methods written long ago, and no kitten died so far (at least not because of that).
由于我的语言(葡萄牙语)是重音符号,因此如果我们的代码库包含这些字符,这很有意义,因为C#明确允许它.
Since my language (portuguese) is accented, it wold make a lot of sense if our codebase has those characters, since C# explicitly allows it.
所以问题是:
是否有
sound技术上的理由不在C#/VisualStudio代码库中使用Unicode字符?
Are there any
soundTECHNICAL reason not to use unicode characters in C#/VisualStudio codebases?
不使用Unicode变量名称的一些原因:
A few reasons why not to use Unicode variable names:
- 这使人们很难打字
- 某些Unicode字符看上去与非母语使用者非常相似(请参见土耳其语I的情况)
- 某些编辑器可能无法正确显示它们
- https://twitter.com/Stephan007/status/481001490463866880/photo/1
- It makes it hard for people to type them
- Some Unicode characters look very similar to non-native speaker (see the case of the Turkish I)
- Some editors might not display them correctly
- https://twitter.com/Stephan007/status/481001490463866880/photo/1