在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?

请每个回答只回答一个特征。


当前回答

让我们为所有试图废除保留词的语言(如PL/I)投票。

还有什么地方可以合法地写出这样有趣的表达:

IF IF THEN THEN = ELSE ELSE ELSE = THEN

(IF, THEN, ELSE是变量名)

or

IF IF THEN THEN ELSE ELSE

(IF为变量,THEN和ELSE为子程序)

其他回答

在C。

int;

(&a)[0] = 10;/*将值10赋给*/

[0]等于*(&a +0)得到*(&a)也就是a。

INTERCAL可能是最奇怪的语言特征的最佳汇编。我个人最喜欢的是COMEFROM语句,它(几乎)与GOTO相反。

COMEFROM is roughly the opposite of GOTO in that it can take the execution state from any arbitrary point in code to a COMEFROM statement. The point in code where the state transfer happens is usually given as a parameter to COMEFROM. Whether the transfer happens before or after the instruction at the specified transfer point depends on the language used. Depending on the language used, multiple COMEFROMs referencing the same departure point may be invalid, be non-deterministic, be executed in some sort of defined priority, or even induce parallel or otherwise concurrent execution as seen in Threaded Intercal. A simple example of a "COMEFROM x" statement is a label x (which does not need to be physically located anywhere near its corresponding COMEFROM) that acts as a "trap door". When code execution reaches the label, control gets passed to the statement following the COMEFROM. The effect of this is primarily to make debugging (and understanding the control flow of the program) extremely difficult, since there is no indication near the label that control will mysteriously jump to another point of the program.

通知7。一个有效程序的例子:

    Chomsky is a room. 
    A thought is a kind of thing. 
    Color is a kind of value. 
    The colors are red, green and blue. 
    A thought has a color. It is usually Green. 
    A thought can be colorful or colorless. It is usually colorless. 
    An idea is a thought in Chomsky with description "Colorless green ideas sleep furiously." 
    A manner is a kind of thing. 
    Furiously is a manner. 
    Sleeping relates one thought to one manner. 
    The verb to sleep (he sleeps, they sleep, he slept, it is slept, he is sleeping) implies the sleeping relation. 
    Colorless green ideas sleep furiously. 

像图灵机模拟器这样的其他愚蠢的东西可以找到。

在Python中,至少对我来说,这是非常wft的!我第一次看的时候:

>>> "ja " * 5
'ja ja ja ja ja '

你可以将字符串相乘!WTF ? ?

PS:我认为这是因为x * n意味着:n乘以x,所以,5次“ja”是“ja”“ja”“ja”“ja”“ja”“ja”,因为你可以像这样连接字符串:

>>> "ja ""ja ""ja ""ja ""ja "
'ja ja ja ja ja '

两个代码有相同的结果(可能是相同的)

在JavaScript中,看到!!第一次使用A(作为一种转换为布尔值的方式)。