Why in interpreted languages the # usually introduces a comment?

南楼画角 提交于 2019-12-12 18:09:34

问题


Why in interpreted languages the # normally introduces a comment? This question was asked in an exam on Shell Programming but I don't find any hint on why it's the #.

Any ideas?


回答1:


make uses the #-comment construct; and sh, one the first shells, uses the same #-comment. The writers of later shells -- csh, ksh, bash, jsh, and more -- understood that it would be a burden on users if each were to have its own comment convention, particularly since all of these shell scripts can sort-of run under any shell.

To invent yet another comment convention would be to ensure that no one would use any newly-introduced shell.

The #-comment became a de facto standard very early in Unix history.

That's my take, anyway.

-- pete



来源:https://stackoverflow.com/questions/4995805/why-in-interpreted-languages-the-usually-introduces-a-comment

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