问题描述
为什么在解释语言中#通常会引入注释?这个问题是在Shell编程考试中被问到的,但是我没有找到为什么它是#的任何提示。
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 #.
任何想法吗?
推荐答案
make使用#注释构造;和sh(第一个外壳程序)使用相同的#注释。后来的shell(csh,ksh,bash,jsh等)的作者理解,如果每个人都有自己的注释约定,这将给用户带来负担,特别是因为所有这些shell脚本都可以运行在任何壳下。
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.
要发明另一种注释约定,就是要确保没有人会使用任何新引入的shell。
To invent yet another comment convention would be to ensure that no one would use any newly-introduced shell.
#注释在Unix历史上很早就成为事实上的标准。
The #-comment became a de facto standard very early in Unix history.
无论如何,这就是我的想法。
That's my take, anyway.
-皮特
这篇关于为什么在解释语言中#通常引入注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!