由于(变量)名称区分大小写而导致的运行时错误

发布于 2024-08-13 18:28:04 字数 598 浏览 1 评论 0原文

我们最近遇到了一个问题(ANTLR“无法启动调试器。等待连接到远程解析器超时。”)其中存在运行时错误,可能是由于(变量)名称区分大小写造成的并且依赖于操作系统。这是在 ANTLR 中,但我更想知道是否存在常见情况(在任何语言中),其中名称仅在程序编译时有所不同,但由于名称冲突而存在运行时错误。 UNIX 和 Windows 之间是否也可能存在差异?

作为一个可能的示例,我可以在同一个包中创建两个 Java 类: Foo.java 中的 Foofoo.java 中的 foo 在 UNIX 上,而我不能在 Windows 上做同样的事情?如果不是,这是否被编译器捕获以及它对大小写相等有何限制?而其他通用语言又是如何处理这个问题的呢?

[当然,我并不是故意尝试这样做,但错误会悄悄出现,而且我严重依赖编译器来检测它们。]

We recenly had a problem (ANTLR “Cannot launch the debugger. Time-out waiting to connect to the remote parser.”) where there was a runtime bug which could have been due to case-sensitivity in (variable) names and was OS-dependent. This was in ANTLR but I am wondering more generally whether there are common cases (in any language) where names differ only in case, the program compiles, but there are runtime errors due to name collisions. Is there also likely to be a difference between UNIX and Windows?

As a possible example can I create two Java classes in the same package:
Foo in Foo.java and
foo in foo.java
on UNIX while I cannot do the same on Windows? If not, is this trapped by the compiler and what restriction does it put on case equality? And how do other common languages treat this problem?

[Of course I don't deliberately try to do this, but errors creep in and I rely heavily on compilers to detect them.]

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

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

发布评论

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

评论(1

初心未许 2024-08-20 18:28:04

大多数人似乎并不太关心这个问题

This does not appear to be of great concern to most people

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