在你看来,你遇到过的最令人惊讶、最怪异、最奇怪或最“WTF”的语言特性是什么?

请每个回答只回答一个特征。


当前回答

在JavaScript中:

alert(111111111111111111111) // alerts 111111111111111110000

这对我在JSON中来回传递的一些64位键非常不利。

其他回答

A very tiny thing that annoyed me in COBOL was that there was no dedicated modulo operation. Instead you could do a division specifying that you only wanted whole number results and store the rest in a different variable. Since COBOL is very sensitive when it comes to variables that means that you ended up with a variable you didn't really need, i.e. the actual result of the division. This is the story of how I once named a variable "USELESS" - that was the most appropriate name I could think of.

其他奇怪的事情:

在c++中,覆盖一个虚方法会隐藏该方法的所有其他重载。在Java中,这种情况不会发生。这很烦人。例如:http://codepad.org/uhvl1nJp

在c++中,如果基类有一个公共虚方法foo(),子类有一个私有方法foo(),这个私有方法会覆盖另一个方法! 这样,只需将子类对象指针强制转换为父类对象指针,就可以在类外部调用私有方法。这不应该是可能的:这违反了封装。新方法不应被视为对旧方法的重写。例如:http://codepad.org/LUGSNPdh

在PHP中,你可以定义函数来接受类型化参数(例如,对象是某个接口/类的子类),讨厌的是,在这种情况下,你不能使用NULL作为实际的参数值。 例如:http://codepad.org/FphVRZ3S

我在试图找出一个完全没有意义但无论如何都能工作的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";

我不知道这是否是真的,但我们偶然发现VS FORTRAN(66或77)不支持递归。递归是偶然的,我们的默认F77支持它很漂亮,但当我们把源代码IBM - Whatta混乱。

作为一名NHibernate爱好者,当我从Smalltalk听到be时,我非常激动……如。

a become: b

它直接将a对象更改为b,这使得编写惰性初始化代理变得很简单,因为所有对a的引用现在都将引用b。非常简洁!

我认为这是一种奇怪的语言特征,因为据我所知,没有其他语言具有这种能力。