在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
Powerbasic (www.powerbasic.com)包含编译器指令:
# BLOAT {bloatsize}
这将使编译后的可执行文件的大小增加<bloatsize>字节。这是放在编译器中,以防创建可执行文件的人不喜欢生成的可执行文件的小尺寸。它使EXE看起来更大,以与臃肿的编程语言竞争:)
其他回答
ANSI SQL中空值的三值逻辑。
在Visual Basic 7及以上版本中,我发现实现了短路逻辑求值以保持与遗留的Visual Basic <=6代码的兼容性,有点WTF:
而且 (MSDN) OrElse (MSDN)
Javascript中有很多东西会让你流泪。
局部变量的作用域,举个简单的例子:
function foo(obj)
{
for (var n = 0; n < 10; n++)
{
var t; // Here is a 't'
...
}
t = "okay"; // And here's the same 't'
}
大约20年前,我用一个编译器为一种叫做Coral的语言工作,它允许我声明只写变量!
不过,这是有道理的,因为它们是全球性的,被用作一种信号机制。一个进程写入值,另一个进程读取值。
PHP对字符串中数值的处理。详见之前对另一个问题的回答,但简而言之:
"01a4" != "001a4"
如果你有两个包含不同数量字符的字符串,它们不能被认为是相等的。前导零很重要,因为它们是字符串而不是数字。
"01e4" == "001e4"
PHP doesn’t like strings. It’s looking for any excuse it can find to treat your values as numbers. Change the hexadecimal characters in those strings slightly and suddenly PHP decides that these aren’t strings any more, they are numbers in scientific notation (PHP doesn’t care that you used quotes) and they are equivalent because leading zeros are ignored for numbers. To reinforce this point you will find that PHP also evaluates "01e4" == "10000" as true because these are numbers with equivalent values. This is documented behaviour, it’s just not very sensible.