Why they used ; to end statements in Java/C++

我是研究僧i 提交于 2019-12-22 00:34:39

问题


Should not they have used . to end a statement. They could use -> to call a method. Was this just a oversight? Or there is some deeper going on here?


回答1:


Java picked the semicolon to have a syntax similar to C and C++.

C++ picked it to have a syntax similar to C.

And I would guess that C picked the semicolon because B, ALGOL and Pascal already used it, and there was no reason not to use an already accepted convention.




回答2:


EDIT: see https://softwareengineering.stackexchange.com/questions/139482/why-are-statements-in-many-programming-languages-terminated-by-semicolons#139485

... so people understand the comment (and negs), this was the original:

"Additionally, the semicolon stands for a NOP (no operation or null command) in C/C++" might give a clue as to why it's common

http://en.wikipedia.org/wiki/Semicolon#Computing_usage



来源:https://stackoverflow.com/questions/10254588/why-they-used-to-end-statements-in-java-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!