在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?
请每个回答只回答一个特征。
当前回答
有些奇怪——VBScript有一个Null关键字和一个Nothing关键字(Null是丢失的数据,Nothing是丢失的对象)。为什么不只有一个关键词…?大多数其他语言似乎都可以用一个!
Visual Basic 6.0当然还有“经典ASP”代码(因为它使用VBScript)也有同样的奇怪之处。在Visual Basic的新旧版本中,我们都有DBNull。
然而,这种情况正在改善,就像Visual Basic一样。NET Null终于消失了,所以Null不再使用,只有Nothing和DBNull被使用。
其他回答
在JavaScript(和Java)中,你可以转义这样有趣的字符:
var mystring = "hello \"world\"";
如果你想把回车放到字符串中,那是不可能的。你必须像这样使用\n:
var mystring = "hello, \nworld";
这是正常的,也是意料之中的——至少对于一种编程语言来说。奇怪的是你也可以像这样转义一个实际的回车:
var mystring = "hello, \
world";
从技术上讲,WTF不是一种语言,而是一种架构。
http://www.6502.org/tutorials/6502opcodes.html#JMP
6502总成,间接JMP:
注意,间接跳转没有进位,因此: 间接跳转绝对不能使用 从最后一个字节开始的向量 一页的 例如,如果地址$3000包含$40,$30FF包含$80,$3100包含$50,JMP ($30FF)的结果将是控制权转移到$4080,而不是你想要的$5080,即6502从$30FF获取地址的低字节,从$3000获取高字节。
因此,在代码中添加一个字节可能会使间接跳转偏离目标。
在JavaScript中:
alert(111111111111111111111) // alerts 111111111111111110000
这对我在JSON中来回传递的一些64位键非常不利。
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.
INTERCAL中的一元运算符(AND, OR和XOR)。