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

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


当前回答

在awk中,数组从索引1开始,这是最不容易混淆的。

其他回答

在C或c++中,sizeof…参数的圆括号是可选的。假设参数不是类型:

void foo() {
  int int_inst;

  // usual style - brackets ...
  size_t a = sizeof(int);
  size_t b = sizeof(int_inst);
  size_t c = sizeof(99);

  // but ...
  size_t d = sizeof int_inst; // this is ok
  // size_t e = sizeof int; // this is NOT ok
  size_t f = sizeof 99; // this is also ok
}

我一直不明白这是为什么!

我肯定会给Perl提供多个可怕的例子:

if(!$#var)

or

if($mystring =~ m/(\d+)/) {

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

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

JCL条件返回执行。

//STEP02 EXEC PGM=PROG02,COND=(4,GT,STEP01) .

该特性允许您根据前面步骤的返回代码运行或不运行某个步骤。真是个不错的功能。

除了一些小功能,把逻辑颠倒过来。

首先,如果条件为真,则不运行步骤。

其次,4 GT,STEP01实际上意味着“如果STEP01的返回码大于4”

因此,整个过程意味着“如果来自STEP01的返回代码大于4,则不要运行此步骤”。这与“如果4大于来自STEP01的返回代码,则运行步骤”的简单解释几乎相同,但并不完全相同。

考虑到你唯一认真看待这些事情的时间是凌晨2点30分左右,电话另一端是一个疯狂的夜班接线员,这种双重模糊会导致严重的头痛。

我一直是PHP错误的忠实粉丝,当在一行中使用两个冒号时脱离上下文:

解析错误:语法错误,第3行/path/to/file/error.php中的T_PAAMAYIM_NEKUDOTAYIM异常

第一次遇到这种情况时,我完全被弄糊涂了。