你遇到过的源代码中最好的注释是什么?


当前回答

当我在高中上计算机课的时候,我们在一个普通的教室里上课——没有电脑。我们所有的测试都是在纸上完成的,一张纸上有一节课。我们的老师是第一次用c++授课,偶尔会在黑板上切换到Pascal模式。这很尴尬,因为我们中很少有人对学习帕斯卡感兴趣。

对于比课堂作业更大的作业,我们会在家里做,并提交代码和输出打印结果来评分。在提交了一些代码+输出输出后,我们共同意识到老师实际上并没有阅读代码-只是打印输出。为了测试我们的理论,我在代码的第三页放了一条注释——就在一些类声明之间:

// If you are reading this, please place a checkmark here [  ]

当然,我把它拿回来的时候,前面有一个大大的蓝色“a”,没有任何标记。

其他回答

一些来自Linux内核的代码:

/* Sun, you just can't beat me, you just can't.  Stop trying,
* give up.  I'm serious, I am going to kick the living shit
* out of you, game over, lights out.
*/

-

/* 2,191 lines of complete and utter shit coming up... */

-

#if 0 /* XXX No fucking way dude... */

在PeopleSoft Financials PeopleCode的早期版本中:

/* I don't know how you can ever get here so I'll have to fix it later */
public static final void attachListener(Object listener) {

/* ======================= */

// This does nothing, continue searching

/* ======================= */

...

与听众一起痛苦!

  rescue
    # silently, we fail
    # many validations fade
    # like tear drops in rain
  end

这只是众多案例中的一个……

v.bpc     := v.pc;  -- Remember to jump back
v.baccu   := accu;  -- Yo dawg, heard you like runing instructions
                    -- so I took backup of your accu so you can run
                    -- instructions while you run instructions.
v.flags.i := false; -- No more interupts