在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
在fortran中(当然是77,可能在95中也是如此),未声明的变量和以I到N开头的参数(“In”组)将是INTEGER,所有其他未声明的变量和参数将是REAL(源)。这与“在某些情况下可选的空白”相结合,导致了最著名的错误之一。
正如弗雷德·韦伯在1990年的《另类民间传说:计算机》一书中所说:
I worked at Nasa during the summer of 1963. The group I was working in was doing preliminary work on the Mission Control Center computer systems and programs. My office mate had the job of testing out an orbit computation program which had been used during the Mercury flights. Running some test data with known answers through it, he was getting answers that were close, but not accurate enough. So, he started looking for numerical problems in the algorithm, checking to make sure his tests data was really correct, etc. After a couple of weeks with no results, he came across a DO statement, in the form: DO 10 I=1.10 This statement was interpreted by the compiler (correctly) as: DO10I = 1.10 The programmer had clearly intended: DO 10 I = 1, 10 After changing the . to a , the program results were correct to the desired accuracy. Apparently, the program's answers had been "good enough" for the sub-orbital Mercury flights, so no one suspected a bug until they tried to get greater accuracy, in anticipation of later orbital and moon flights. As far as I know, this particular bug was never blamed for any actual failure of a space flight, but the other details here seem close enough that I'm sure this incident is the source of the DO story.
我认为这是一个很大的WTF,如果DO10I被作为DO10I,并且反过来,因为隐式声明被认为是类型REAL。这是个很棒的故事。
其他回答
在J中,foreign(!:)是各种函数组合在一起。左边的参数是一个类别,右边的参数通常(但不总是)是不同的增量值。的东西。例如:
2!:55 NB. Close console 9!:10 NB. Set print precision 6!:0 NB. Actual time 6!:2 NB. Execution time 4!:3 NB. Loaded scripts
当然,聪明的做法是把它们包装起来,但有些你只需要记住。顺便说一句,所有这些都是,想想看,三位一体的,有两个参数在右边,一个在左边。除非你给他们一个最终有效的论据,否则以上任何一条都不会起作用。
Tcl在解释器中虚拟化的时间钩子非常奇怪: http://www.tcl.tk/cgi-bin/tct/tip/233.html
基本上,它允许你让解释器使用一些其他的时间数据源,例如,先在模拟器中运行硬件测试,然后替换计时器函数,对真实的东西运行相同的测试。
C和c++中的三联体。
int main() {
printf("LOL??!");
}
这将打印LOL|,因为trigraph ??!转换为|。
在C。
int;
(&a)[0] = 10;/*将值10赋给*/
[0]等于*(&a +0)得到*(&a)也就是a。
In C
a[i++] = i;
它会编译,但很少执行您认为它应该执行的操作。优化更改会产生截然不同的结果。它在不同平台上的运行方式也不同。
然而,编译器对此非常满意。