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

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


当前回答

我想到的第一件事是“noop”,当我第一次看到它时,我的大脑也做了同样的事情!

其他回答

在俄亥俄州立大学,他们用一种叫做Resolve/ c++的杂种c++语言教授编程。Resolve/ c++对一切都使用契约式设计方法。它要求您在编译后的注释中对组件和方法进行数学建模,从而强制您维护方法和对象之间的require /ensure关系。

在JavaScript中,下面的构造

return
{
    id : 1234,
    title : 'Tony the Pony'
};

返回undefined是一个语法错误,因为在返回后的换行上偷偷地插入了分号。以下工作正如你所期望的那样:

return {
    id : 1234,
    title : 'Tony the Pony'
};

更糟糕的是,这个也可以(至少在Chrome中):

return /*
*/{
    id : 1234,
    title : 'Tony the Pony'
};

下面是同一个问题的一个变种,它不会产生语法错误,只是无声地失败了:

return
    2 + 2;

VBScript的With block:

With xml.appendChild(xml.createElement("category"))
  .setAttribute("id",id)
  .setAttribute("keywords",keywords)
  With .appendChild(xml.createElement("item"))
    .setAttribute("count",count)
    .setAttribute("tip",tip)
    .appendChild(xml.createTextNode(text))
  End With
End With

C和c++中的三联体。

int main() {
   printf("LOL??!");
}

这将打印LOL|,因为trigraph ??!转换为|。

不久前,当我在CS课上第一次发现C语言时,看到指针的行为方式是非常奇怪的。我们只是编写程序并猜测它会做什么,直到它们得到正确的行为