在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
对于那些从未使用过COBOL的人来说,这是一个常见的代码行,但它不做您可能想做的事情
图片XXX
其他回答
英语中的虚拟语气。
等等,你是说编程语言吗?然后在C中使用(宏)绕过宏()的预处理器#定义。例如,如果有人使用#define free(…),(free)(…)将与free(…)不同。
C / C + +:
快速平方根逆算法利用了IEEE浮点表示法(代码复制自维基百科):
float InvSqrt(float x)
{
union {
float f;
int i;
} tmp;
tmp.f = x;
tmp.i = 0x5f3759df - (tmp.i >> 1);
float y = tmp.f;
return y * (1.5f - 0.5f * x * y * y);
}
因为我还没见过任何人提起它……RPG 2或3(报告程序生成器…又名火箭推进垃圾)是迄今为止我用过的最疯狂的语言。它几乎没有对程序流的控制(在文件顶部的Enter,在底部的Exit),并且编程语句是基于使用固定字体在特定列中定义的字符定义的(想想PUNCH CARDS!!)
要真正做到FUBAR,你必须尝试用DYL-280编程。它将RPG流程和逻辑与COBOL语法结合在一起。
在这里查找RPG: wikipedia.org /wiki/IBM_RPG
DYL-280的示例:http://99-bottles-of-beer.net/language-dyl-280-224.html
C# has a feature called "extension methods", which are roughly analogous to Ruby mix-ins - Essentially, you can add a method to any pre-existing class definition (for instance, you oould add "reverse()" to String if you were so inclined). That alone is fine- The "Weird" part is that you can add these extension methods, with a method body and everything, to an interface. On the one hand, this can be handy as a way to add a single method to a whole swath of classes which aren't part of the same inheritance tree. On the other, you're adding fleshed out methods to interfaces, essentially breaking the very definition of an interface.
对于那些从未使用过COBOL的人来说,这是一个常见的代码行,但它不做您可能想做的事情
图片XXX