在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
在SQL Server中,如果你在生产代码中使用select *,你可能会遇到一个令人讨厌的意外。无论如何,使用select *并不被认为是一个好的实践,但了解一些有趣的行为是很好的。
参见问题“select * from table”vs“select colA,colB etc from table”在SqlServer2005中有趣的行为了解更多细节
其他回答
对于那些不知道的人来说,PostScript实际上是一种编程语言。我已经有点疯狂了——我写了一个PostScript程序,计算曼德尔布罗特分形的细节非常高。它真的是可打印的PostScript,尽管它会崩溃很多打印驱动程序…
总之,从哪里开始PostScript…这里有一个例子:您实际上可以创建一个标识符为....的变量什么都没有。
() cvn 5 def %将数字5分配给…没有什么
PostScript是一种基于堆栈的语言。()将一个空字符串放入堆栈。cvn将其转换为一个名称(如果打印它,则为“/”,因为PS中的所有名称前面都有斜杠)。然后5def将值5赋给它。(%是注释字符)
你不能直接把它拿回来,例如,如果我说“/ print”,这将不会打印数字5。但你可以间接地把它拿回来:
() CVN负载打印%这将打印数字5
还有什么……PostScript将字典作为原生类型,您可以使用数组引用作为字典的键…但是REFERENCE才是键,而不是数组。所以:
/myDict 100 dict def
[0] dup myDict exch 42 put myDict exch get == %打印42
myDict [1] 42 put myDict [1] get %抛出未定义错误
编辑:哦,是的,还有一件有趣的事情……在Ghostscript提示下尝试以下操作:
1 array dup dup 0 exch put ==
分析!
我不知道这是否是真的,但我们偶然发现VS FORTRAN(66或77)不支持递归。递归是偶然的,我们的默认F77支持它很漂亮,但当我们把源代码IBM - Whatta混乱。
我最喜欢的奇怪的C语言是5[“Hello World”],但因为已经发布了,我最喜欢的第二个奇怪的是Windows版本结构初始化黑客:
void someWindowsFunction() {
BITMAPINFOHEADER header = {sizeof header};
/* do stuff with header */
}
这条微妙的线条达到了以下效果:
Declares a BITMAPINFOHEADER structure Concisely sets the "size" member of the structure, without hardcoding a size constant (since many Window structures, including BITMAPINFOHEADER, follow the convention of specifying the size of the structure as the first member} Declares the version of the structure (since many Windows structures, including BITMAPINFOHEADER, identify their version by the declared size, following the convention that structures definitions are append-only) Clears all other members of the structure (a C standard behavior when a structure is incompletely initialized).
很久以前,我曾经用BUT子句构建过一种语言。
不知道它是否可以被认为是一种语言特性,但是,在c++中,几乎任何与模板相关的编译器错误都会每天向世界各地的许多c++程序员交付相当数量的WTF:)