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


当前回答

在为一家芬兰移动网络设备制造商工作期间,我深入研究了硬件抽象层,发现芬兰语单词“puukko”出现了100多次。

“puukko”是一种万能刀,每个芬兰人的工具箱里或家里都有。它被用于从剥土豆到电脑维修(我的观察)的所有事情。我相信在这个语境中,它相当于芬兰语中的“Hack”。

我的芬兰同事否认了这一点,并说这更像是“外科手术/干预”……我差点就相信了,直到我看到下面的评论:

/* Perkele ISO Puukko! */ -> Fucking Big Hack!

其他回答

//这将为我们每个用户节省0.5秒,并取悦机器精神。

在很长的程序之前:)

我喜欢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.  */
// sometimes I believe compiler ignores all my comments

最近在我们的代码中发现了这一点(我们开发企业软件):

// Instance of excel
Excel excel = this.CreateExcelInstance();
excel.Open(stream); // how to close it?!

在此之前,我确信我们已经摆脱了这些“有趣的东西”,我们正在以正确的、意识形态正确的方式做这件事……

Linux的评论

这里有很多不错的……

这些都是linux中的注释

http://lwn.net/1998/1015/a/f-word.html

我的最爱:

./arch/sparc/kernel/ptrace.c
/* Fuck me gently with a chainsaw... */

./drivers/scsi/qlogicpti.h
/* Am I fucking pedantic or what? */