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

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


当前回答

通知7。一个有效程序的例子:

    Chomsky is a room. 
    A thought is a kind of thing. 
    Color is a kind of value. 
    The colors are red, green and blue. 
    A thought has a color. It is usually Green. 
    A thought can be colorful or colorless. It is usually colorless. 
    An idea is a thought in Chomsky with description "Colorless green ideas sleep furiously." 
    A manner is a kind of thing. 
    Furiously is a manner. 
    Sleeping relates one thought to one manner. 
    The verb to sleep (he sleeps, they sleep, he slept, it is slept, he is sleeping) implies the sleeping relation. 
    Colorless green ideas sleep furiously. 

像图灵机模拟器这样的其他愚蠢的东西可以找到。

其他回答

对于那些从未使用过COBOL的人来说,这是一个常见的代码行,但它不做您可能想做的事情

图片XXX

不久前,当我在CS课上第一次发现C语言时,看到指针的行为方式是非常奇怪的。我们只是编写程序并猜测它会做什么,直到它们得到正确的行为

Perl的许多内置变量:

$# — not a comment! $0, $$, and $? — just like the shell variables by the same name $ˋ, $&, and $' — weird matching variables $" and $, — weird variables for list- and output-field-separators $! — like errno as a number but strerror(errno) as a string $_ — the stealth variable, always used and never seen $#_ — index number of the last subroutine argument... maybe @_ — the (non)names of the current function... maybe $@ — the last-raised exception %:: — the symbol table $:, $^, $~, $-, and $= — something to do with output formats $. and $% — input line number, output page number $/ and $\ — input and output record separators $| — output buffering controller $[ — change your array base from 0-based to 1-based to 42-based: WHEEE! $} — nothing at all, oddly enough! $<, $>, $(, $) — real and effective UIDs and GIDs @ISA — names of current package’s direct superclasses $^T — script start-up time in epoch seconds $^O — current operating system name $^V — what version of Perl this is

还有很多这样的东西。点击这里阅读完整列表。

一般来说,弱类型。

C:

printf("%c\n", 'a' + 3);

PHP:

echo 5 + "3";

还有太多其他语言。

好吧,既然问题是断断续续的,我就加入到“有趣”中来

Go(又名Issue9)使用大写的可见性:

如果你用大写字母命名某个东西,它就会被公众访问。 如果你使用小写,它将被包保护:

包装外可见:

func Print(v ...) { 
}

包外不可见

func print( v ... ) {
}

你可以在这个原始答案中找到更多。