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

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


当前回答

Objective-C对字符串@的使用。示例:@"这是一个字符串。"

其他回答

我很惊讶居然没有人提到Visual Basic的7个循环结构。

For i As Integer = 1 to 10 ... Next
While True ... End While
Do While True ... Loop
Do Until True ... Loop
Do ... Loop While True
Do ... Loop Until True
While True ... Wend

因为粘!你面前的条件实在是太复杂了!

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.

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

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

IF IF THEN THEN = ELSE ELSE ELSE = THEN

(IF, THEN, ELSE是变量名)

or

IF IF THEN THEN ELSE ELSE

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

ANSI SQL中空值的三值逻辑。

在C语言中,数组可以像这样被索引:

a[10]

这很常见。

然而,鲜为人知的形式(真正有效!)是:

10[a]

这与上面的意思相同。