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

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


当前回答

这里有一大堆奇怪的C特性:http://www.steike.com/code/useless/evil-c/

其他回答

在Ruby中…

i=true
while(i)
   i=false
   a=2
end
puts defined?(a) // returns true

在C或c++中,使用宏可以获得很多乐趣。如

#define FOO(a,b) (a+b)/(1-a)

如果传入FOO(bar++,4),它将使a增加两次。

回想起来,FORTRAN的计算goto是相当奇怪的。维基百科告诉我一些基础知识胜过它。

另一个著名的最爱是Algol 60的名称参数调用传递。

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

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

Perl有yada yada操作符(…)。

Perl 6传统的所谓“yada yada”操作符是标记未实现代码的快捷方式:

if ($condition) { ... }

if ($condition) { die "not yet implemented" }