在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
我最喜欢的奇怪的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).
其他回答
因为我还没见过任何人提起它……RPG 2或3(报告程序生成器…又名火箭推进垃圾)是迄今为止我用过的最疯狂的语言。它几乎没有对程序流的控制(在文件顶部的Enter,在底部的Exit),并且编程语句是基于使用固定字体在特定列中定义的字符定义的(想想PUNCH CARDS!!)
要真正做到FUBAR,你必须尝试用DYL-280编程。它将RPG流程和逻辑与COBOL语法结合在一起。
在这里查找RPG: wikipedia.org /wiki/IBM_RPG
DYL-280的示例:http://99-bottles-of-beer.net/language-dyl-280-224.html
在Ruby中…
i=true
while(i)
i=false
a=2
end
puts defined?(a) // returns true
我想到的第一件事是“noop”,当我第一次看到它时,我的大脑也做了同样的事情!
c#中的“动态”。
因为智能感知、类型安全和决定论会随着“动态”关键字的第一次使用而立即消失,因此所有必须与RAD或python受害者一起工作的人的日子都被毁了。
在PHP中:
<?php
$o = new stdClass;
echo count($o);
?>
..打印1。一直不知道为什么。