在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
我很惊讶没有人提到大多数类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 -,-");
}
好在新语言正确地实现了它。
其他回答
在J中,大多数原语(也就是函数)是一元的(一个参数)或二元的(两个参数,一个在左边,一个在右边)。但是修正原语需要3个(我认为这是唯一一个,除了foreign)。这是可以理解的,它需要3个,但它只是看起来…一开始是错的。
vector =: i. 10 NB. Vector will be 0 1 2 3 4 5 6 7 8 9
(10) (0) } vector NB. Will yield 10 1 2 3 4 5 6 7 8 9
我喜欢在C中插入八进制值:
int values[8] = { 123, 154, 103, 310, 046, 806, 002, 970 };
Delphi不关心像“word”这样的类型转换,将读取数组arr[0..65535] where pos = 65535: Arr[单词(pos + 10)]
这可能已经被提到了,但是——
PHP对八进制值的处理:
$a = 07; // 7 (as it should be)
$b = 08; // 0 (would be an error in any sensible language)
$c = 018; // 1 (again, should have been an error)
$d = 0A; // error (as it should be)
请看这里:http://bugs.php.net/bug.php?id=29676
还要注意关于这个错误的评论——Derick称其为一个特性(引用“fix”表示),而不是一个错误,他声称它会“在脚本中使用数字的所有情况下显著降低PHP的速度”——但是,为什么PHP会引发一个0A错误呢?
我认为人们可以写一整本书来讲述PHP的古怪之处……
我在试图找出一个完全没有意义但无论如何都能工作的MACRO时遇到了这个。这对于objective-c是正确的,但对于其他类型的C(或者至少是gcc编译器)也可能是正确的。
NSString *oneString = @"This " @"is " @"just " @"one " @"normal " @" string";
=
NSString *oneString = @"This is just one normal string";
C风格的字符串也是如此
char* str = "this " "also " "works";