由于(变量)名称区分大小写而导致的运行时错误
我们最近遇到了一个问题(ANTLR“无法启动调试器。等待连接到远程解析器超时。”)其中存在运行时错误,可能是由于(变量)名称区分大小写造成的并且依赖于操作系统。这是在 ANTLR 中,但我更想知道是否存在常见情况(在任何语言中),其中名称仅在程序编译时有所不同,但由于名称冲突而存在运行时错误。 UNIX 和 Windows 之间是否也可能存在差异?
作为一个可能的示例,我可以在同一个包中创建两个 Java 类: Foo.java
中的 Foo
和 foo.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
andfoo
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
大多数人似乎并不太关心这个问题
This does not appear to be of great concern to most people