What language(s) have comments with side effects? In essence, comments which are not comments....
哪些语言有副作用的评论?本质上,评论不是评论....
8 个解决方案
#1
3
I can think of several places where comments aren't really comments.
我可以想到几个评论不是真正评论的地方。
- HTML and script tags (providing support for browsers that don't allow or support scripts).
HTML和脚本标记(为不允许或支持脚本的浏览器提供支持)。
And then, considerably more obscurely:
然后,更加模糊:
- IBM Informix 4GL (I4GL) and 4J's Genero (successor to Informix Dynamic 4GL, D4GL). The notation '
--#
' was used by D4GL to include material only applicable to D4GL; I4GL would see that as a comment. The inverse notation was '--@
', which looked like a comment to D4GL but was treated as active material by I4GL.
IBM Informix 4GL(I4GL)和4J的Genero(Informix Dynamic 4GL,D4GL的后继者)。 D4GL使用符号“ - #”来包含仅适用于D4GL的材料; I4GL会将其视为评论。反符号是' - @',它看起来像是对D4GL的评论,但被I4GL视为活动素材。
And, even more obscurely:
而且,更加模糊:
- I wrote an I4GL file which was dual-languaged, exploiting I4GL's multiple comment facilities. Material starting '
#
' (hash) marked the start of a comment outside of strings - up to the next newline, as does '--
' (double-dash). Also, '{...}
' (braces) enclose multiline comments. - The top of the source file was actually a shell script, mostly enclosed in '
{...}
' which is, of course, perfectly legitimate in shell. The shell script was a data-driven code generator that copied itself to the top of the output, and then generated about 100 functions which were all depressingly similar but slightly different (in a language without templates or a pre-processor). The code had to validate what was in the database for a given ship against incoming data from an external source (Lloyds of London, in fact), to see what had changed since the last time the external data was received. Non-trivial comparison work, especially since it had to deal with database (SQL) nulls. - The file was not really a Quine program, but it had some points in common with it. In particular, you could feed the script broken I4GL code and the regenerated file would be perfect again, basically because it ignored the existing I4GL code.
我写了一个双语言的I4GL文件,利用了I4GL的多个评论工具。材料开头'#'(哈希)标记了字符串之外的注释的开头 - 直到下一个换行符,' - '(双击)。此外,'{...}'(大括号)包含多行注释。
源文件的顶部实际上是一个shell脚本,大多数都包含在“{...}”中,当然,它在shell中是完全合法的。 shell脚本是一个数据驱动的代码生成器,它将自身复制到输出的顶部,然后生成大约100个函数,这些函数都令人沮丧地相似但略有不同(在没有模板或预处理器的语言中)。代码必须验证给定船舶的数据库中针对来自外部源(实际上是Lloyds of London)的传入数据的内容,以查看自上次收到外部数据以来发生了哪些变化。非平凡的比较工作,特别是因为它必须处理数据库(SQL)null。
该文件并不是真正的Quine程序,但它有一些共同点。特别是,您可以提供破坏I4GL代码的脚本,重新生成的文件将再次完美,主要是因为它忽略了现有的I4GL代码。
#2
4
English. Do I win?
英语。我赢吗?
#3
4
DOS Batch Shell programming
DOS Batch Shell编程
The REM (Remark) allows you to put in a comment. But it has the side-effect of modifying the ERRORLEVEL variable to 0.
REM(备注)允许您发表评论。但它具有将ERRORLEVEL变量修改为0的副作用。
In a sense, it makes last operation a success.
从某种意义上说,它使最后的操作成功。
I don't know how a comment can fail, but if it does, you are covered.
我不知道评论如何失败,但如果确实如此,你就会被覆盖。
#4
2
Haskell can turn the usual comments in code paradigm upside down by having code in comments - also Mathematica and the like; literal programming is a nice feature for the more mathematically inclined languages.
Haskell可以通过在评论中使用代码来改变代码范例中的常用注释 - 也可以使用Mathematica等;文字编程对于更具数学倾向的语言来说是一个很好的特性。
I also find annotations in Java are like comments with behaviour.
我还发现Java中的注释就像是带有行为的注释。
#5
1
Then of course there are "polyglots" -- programs which can be compiled/executed in multiple languages. Usually these rely on the fact that the same line is a comment in one language, but an actual line of code in another.
当然还有“polyglots” - 可以用多种语言编译/执行的程序。通常这些依赖于同一行是一种语言的注释,而另一种语言中的实际代码行。
#6
1
QBasic has a use of comments all its own: REM $STATIC
or REM $DYNAMIC
set how arrays are allocated.
QBasic使用自己的注释:REM $ STATIC或REM $ DYNAMIC设置数组的分配方式。
Another example: When web browsers parse comments <!-- -- -->in<!-- -- -->correctly
.
另一个例子:当Web浏览器正确解析 中的注释 时。
#7
0
CSS for clever cross-browser hacks. Of course, I wouldn't really call CSS a language.
用于聪明的跨浏览器黑客的CSS。当然,我不会真的称CSS为语言。
#8
0
Just stumbled upon this old question and my first thought was javadoc comments.
只是偶然发现了这个老问题,我的第一个想法是javadoc评论。
#1
3
I can think of several places where comments aren't really comments.
我可以想到几个评论不是真正评论的地方。
- HTML and script tags (providing support for browsers that don't allow or support scripts).
HTML和脚本标记(为不允许或支持脚本的浏览器提供支持)。
And then, considerably more obscurely:
然后,更加模糊:
- IBM Informix 4GL (I4GL) and 4J's Genero (successor to Informix Dynamic 4GL, D4GL). The notation '
--#
' was used by D4GL to include material only applicable to D4GL; I4GL would see that as a comment. The inverse notation was '--@
', which looked like a comment to D4GL but was treated as active material by I4GL.
IBM Informix 4GL(I4GL)和4J的Genero(Informix Dynamic 4GL,D4GL的后继者)。 D4GL使用符号“ - #”来包含仅适用于D4GL的材料; I4GL会将其视为评论。反符号是' - @',它看起来像是对D4GL的评论,但被I4GL视为活动素材。
And, even more obscurely:
而且,更加模糊:
- I wrote an I4GL file which was dual-languaged, exploiting I4GL's multiple comment facilities. Material starting '
#
' (hash) marked the start of a comment outside of strings - up to the next newline, as does '--
' (double-dash). Also, '{...}
' (braces) enclose multiline comments. - The top of the source file was actually a shell script, mostly enclosed in '
{...}
' which is, of course, perfectly legitimate in shell. The shell script was a data-driven code generator that copied itself to the top of the output, and then generated about 100 functions which were all depressingly similar but slightly different (in a language without templates or a pre-processor). The code had to validate what was in the database for a given ship against incoming data from an external source (Lloyds of London, in fact), to see what had changed since the last time the external data was received. Non-trivial comparison work, especially since it had to deal with database (SQL) nulls. - The file was not really a Quine program, but it had some points in common with it. In particular, you could feed the script broken I4GL code and the regenerated file would be perfect again, basically because it ignored the existing I4GL code.
我写了一个双语言的I4GL文件,利用了I4GL的多个评论工具。材料开头'#'(哈希)标记了字符串之外的注释的开头 - 直到下一个换行符,' - '(双击)。此外,'{...}'(大括号)包含多行注释。
源文件的顶部实际上是一个shell脚本,大多数都包含在“{...}”中,当然,它在shell中是完全合法的。 shell脚本是一个数据驱动的代码生成器,它将自身复制到输出的顶部,然后生成大约100个函数,这些函数都令人沮丧地相似但略有不同(在没有模板或预处理器的语言中)。代码必须验证给定船舶的数据库中针对来自外部源(实际上是Lloyds of London)的传入数据的内容,以查看自上次收到外部数据以来发生了哪些变化。非平凡的比较工作,特别是因为它必须处理数据库(SQL)null。
该文件并不是真正的Quine程序,但它有一些共同点。特别是,您可以提供破坏I4GL代码的脚本,重新生成的文件将再次完美,主要是因为它忽略了现有的I4GL代码。
#2
4
English. Do I win?
英语。我赢吗?
#3
4
DOS Batch Shell programming
DOS Batch Shell编程
The REM (Remark) allows you to put in a comment. But it has the side-effect of modifying the ERRORLEVEL variable to 0.
REM(备注)允许您发表评论。但它具有将ERRORLEVEL变量修改为0的副作用。
In a sense, it makes last operation a success.
从某种意义上说,它使最后的操作成功。
I don't know how a comment can fail, but if it does, you are covered.
我不知道评论如何失败,但如果确实如此,你就会被覆盖。
#4
2
Haskell can turn the usual comments in code paradigm upside down by having code in comments - also Mathematica and the like; literal programming is a nice feature for the more mathematically inclined languages.
Haskell可以通过在评论中使用代码来改变代码范例中的常用注释 - 也可以使用Mathematica等;文字编程对于更具数学倾向的语言来说是一个很好的特性。
I also find annotations in Java are like comments with behaviour.
我还发现Java中的注释就像是带有行为的注释。
#5
1
Then of course there are "polyglots" -- programs which can be compiled/executed in multiple languages. Usually these rely on the fact that the same line is a comment in one language, but an actual line of code in another.
当然还有“polyglots” - 可以用多种语言编译/执行的程序。通常这些依赖于同一行是一种语言的注释,而另一种语言中的实际代码行。
#6
1
QBasic has a use of comments all its own: REM $STATIC
or REM $DYNAMIC
set how arrays are allocated.
QBasic使用自己的注释:REM $ STATIC或REM $ DYNAMIC设置数组的分配方式。
Another example: When web browsers parse comments <!-- -- -->in<!-- -- -->correctly
.
另一个例子:当Web浏览器正确解析 中的注释 时。
#7
0
CSS for clever cross-browser hacks. Of course, I wouldn't really call CSS a language.
用于聪明的跨浏览器黑客的CSS。当然,我不会真的称CSS为语言。
#8
0
Just stumbled upon this old question and my first thought was javadoc comments.
只是偶然发现了这个老问题,我的第一个想法是javadoc评论。