为什么非 ASCII 字符在函数 / var 名称中仍然不受欢迎?

发布于 2024-09-18 09:27:47 字数 356 浏览 4 评论 0原文

当我看到一个为一些学生编写的小程序时,我经常看到这样的内容:(haskell,德语):

ueber = "What the haeck!"

而不是像

über = "What the häck!"

许多现代语言都指定允许通过 UTF-8 在声明名称中使用非标准字符一样,有吗在项目中避免这些字符的特殊原因,这肯定只适用于能够输入这些字符的人(例如德国学生团队?)或者这只是一个历史原因?

我知道,如果您在国际范围内开发应用程序,则应该将名称保留在 a-zA-Z_0-9 中,但是有什么理由在“本地”项目中避免这种情况吗?

When I see a small program which is written for some students, I often see something like this: (haskell, german):

ueber = "What the haeck!"

instead of

über = "What the häck!"

As many modern languages are specified to allow non-standard charactes in declaration names via UTF-8, is there a special reason for avoiding these in a project, which is sure to be only for people who are able to input these characters (say for a team of german students?) or is this just a historical reason?

I know, that you should keep names in a-zA-Z_0-9 if you develop an applicaio internationally, but are there any reason for avoiding this in a "local" project?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

誰ツ都不明白 2024-09-25 09:27:47

是否有特殊原因在项目中避免这些字符,这肯定只适用于能够输入这些字符的人

,这当然是主要原因。我想到的其他原因是许多开发工具、搜索功能、编辑器、解析器、文档记录器、代码搜索引擎等不会期望代码中出现非 ASCII 输入。

此外,您永远不知道有一天您的代码可能会在哪里使用!最小的无辜学校项目可以成长为一个很好的开源工具,有一天会在全球范围内使用。在这种情况下,ASCII 是最小公分母,至少目前是这样。

is there a special reason for avoiding these in a project, which is sure to be only for people who are able to input these characters

That is certainly the main reason. Other reasons that come to mind is that many development tools, search functions, editors, parsers, documentors, code search engines etc. will not expect non-ASCII input in code.

Also, you never know where your code may be used one day! The smallest innocent school project can grow into a nice Open-Source tool that gets used around the globe one day. In that case, ASCII is the smallest common denominator, at least at the moment.

你好,陌生人 2024-09-25 09:27:47

我必须参与一个由法国开发商发起的项目。当越来越多的人加入该项目时,他们不得不花费大量时间将程序翻译成英语。预先教您的德国学生本课,他们不仅能够与其他人共享代码,而且也不再需要 überueber 变量。

顺便说一句,ü 是一个字母字符。 +- 是非字母数字的,我想说这很明显为什么它们在函数名称中不受欢迎。

I've had to work on a project started by French developers. They had to spend quite a bit of time translating their program to English when more people joined the project. Teach your German students this lesson up front, and not only will they be able to share their code with others, they'll no longer need an über or ueber variable either.

BTW, ü is an alphabetic character. + and - are non-alphanumeric, and I'd say it's obvious why they're disliked in function names.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文