可以使用非英语的外语变量名吗? [英] Is it ok to use a non-English, foreign language variable name?

查看:35
本文介绍了可以使用非英语的外语变量名吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对我来说,英语是一座大山.因此,每当我使用 Visual Studio 2017 (C++)、Unity 3D(C#)、Visual Studio Code (html)、Eclipse (java) 和 Android Studio 等工具时,我总是用我的母语分配变量.

例如)

 int get넓이(int 사로, int 세로){int square = 사로 * 세로;返回方块;}

然而,许多人建议不要使用非英文变量名,因为它们会导致错误".但我还没有遇到任何错误.

我还就此问题联系了 Unity Game Engine 客户中心.他们是这样回答我的.您可以通过转到 [Visual Studio → 文件 → 高级保存选项] 来执行此操作,然后将另存为默认编码选项"指定为 UTF-8."

所以,我想知道在用英语以外的语言编程时是否会出错.因为我没有遇到过使用非英文变量名的错误.我也就这个问题联系过其他社区网站,但我没有见过任何人遇到过这个问题.

解决方案

这完全取决于你用什么语言编程.例如,Python3 会支持它(大多数情况下,只要是 Unicode),但是 Python2 不会喜欢它,因为它只支持 ASCII.

与任何代码一样,如果它使您更容易,那就去做吧.如果要部署给其他人,请尽力使其对其他人可读.只需确保您的语言完全支持 Unicode.

For me, English is too big a mountain. So whenever I use tools like Visual Studio 2017 (C ++), Unity 3D(C#), Visual Studio Code (html), Eclipse (java), and Android Studio, I've always assigned variables in my native language.

ex)

    int get넓이(int 가로, int 세로)
    {
        int square = 가로 * 세로;
        return square;
    }

However, many people advised not to use non-English variable names because they can 'cause errors'. But I have not experienced any errors yet.

I also contacted the Unity Game Engine customer center on this issue. And they answered me like this. "You can do this by going to [Visual Studio → File → Advanced Save Options], and then specify" Save as default encoding option "to UTF-8."

So, I wonder if there is an error when programming in a language other than English. because I have not experienced errors using non-English variable names. I have also contacted other community sites on this issue, but I have not seen anyone who experienced the issue.

解决方案

It completely depends on what language you are programming in. For example, Python3 will support it (mostly, as long as it's Unicode), however, Python2 will not like it at all as it only supports ASCII.

As with any code, if it makes it easier for you then do it. Just try your best to make it readable to others if it is going to be deployed to others. Just make sure your language fully supports Unicode.

这篇关于可以使用非英语的外语变量名吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆