在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
C++:
void f(int bitand i){ //WTF
i++;
}
int main(){
int i = 0;
f(i);
cout << i << endl; //1
return 0;
}
其他回答
我有点纠结:
1;
在perl中,模块需要返回true。
Python 2. x
>>>True = False
>>>True
False
你真的可以让一个人变得疯狂。
下面这个我觉得很奇怪:
在C/ c++中,你可以有尽可能多的分号,至少在MS c++中:
int main(void)
{
cout<<"Hello World";;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;
return 0;;;;;;;;;;;;;;;;;;;;;;;
}
反向波兰符号。这意味着实参在函数之前。换句话说,2加2就是2 +。
具有WTF特性的语言包括Forth、Postscript(是的,激光打印机的Postscript)和Factor。
我很惊讶没有人提到大多数类c语言中丑陋的开关case实现
switch (someInt) {
case 1:
case 2: System.out.println("Forgot a break, idiot!");
case 3: System.out.println("Now you're doing the wrong thing and maybe need hours to find the missing break muahahahaha");
break;
default: System.out.println("This should never happen -,-");
}
好在新语言正确地实现了它。