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


当前回答

//Dave chapelle reports errors.
function reporterror() {
  davechapelle.trace("FUCK!");
}

其他回答

// this error could never happen

然后,客户打电话说他看到一条错误消息说"这个错误永远不会发生"

在被迫为贫血域对象编写单元测试时,这些对象不过是getter和setter的包(我也是被迫写的):

// zzzzZZZZzzzz....

对上帝诚实:

// This is crap code but it's 3 a.m. and I need to get this working.

我喜欢GNU双utils中的一些注释。这个来自BFD som.c:

/* You'll never believe all this is necessary to handle relocations
   for function calls.  Having to compute and pack the argument
   relocation bits is the real nightmare.

   If you're interested in how this works, just forget it.  You really
   do not want to know about this braindamage.  */

这个也是:

/* Don't ask about these magic sequences.  I took them straight
   from gas-1.36 which took them from the a.out man page.  */

...

/* Keep track of exactly where we are within a particular
   space.  This is necessary as the braindamaged HPUX
   loader will create holes between subspaces *and*
   subspace alignments are *NOT* preserved.  What a crock.  */

另一个:

/* We will NOT put a fucking timestamp in the header here. Every
   time you put it back, I will come in and take it out again. ... */

从气体:

/* Yes this is ugly (storing the broken_word pointer
   in the symbol slot).  Still, this whole chunk of
   code is ugly, and I don't feel like doing anything
   about it.  Think of it as stubbornness in action.  */
// I love the smell of dirty XML in the morning
xml = xml.Replace("xmlns=\"urn:bsd.orion/inventory\"", "");