在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
在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
当然,聪明的做法是把它们包装起来,但有些你只需要记住。顺便说一句,所有这些都是,想想看,三位一体的,有两个参数在右边,一个在左边。除非你给他们一个最终有效的论据,否则以上任何一条都不会起作用。
其他回答
Fortran中不同列的特殊含义。(如果你从小就有穿孔卡片,这可能是很自然的。)
这样做的一个副作用是,例如变量名在第72列之后被截断。结合隐式NONE,当这样的变量名在第72列附近开始时,它会无声地引入一个新变量。
你需要
要知道这一点 以不同的方式高亮显示注释部分(第72列之后)的编辑器 颜色比之前的部分…
Powerbasic (www.powerbasic.com)包含编译器指令:
# BLOAT {bloatsize}
这将使编译后的可执行文件的大小增加<bloatsize>字节。这是放在编译器中,以防创建可执行文件的人不喜欢生成的可执行文件的小尺寸。它使EXE看起来更大,以与臃肿的编程语言竞争:)
我最喜欢的奇怪的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).
这并不是一个奇怪的特性,但从类型安全的角度来看,它确实令人恼火:c#中的数组协方差。
class Foo { }
class Bar : Foo { }
class Baz : Foo { }
Foo[] foo = new Bar[1];
foo[0] = new Baz(); // Oh snap!
我相信这是从Java继承而来的(双关语)。
下面是一个关于python的例子:
>>> print 07
7
>>> print 08
File "<stdin>", line 1
print 08
^
SyntaxError: invalid token
那不是很美吗?
尤其当你想到人类是如何写日期的时候,你会觉得很不周到,这有以下影响:
datetime.date(2010,02,07) # ok
datetime.date(2010,02,08) # error!
(原因是0x被解释为八进制,所以打印010打印8!)