The Story of Mac: A Just-So Story(Mac 的故事:只是一个故事)
很久以前,有一个由 Lisp 程序员们所组成的公司。由于年代过于久远,所以那个时候的 Lisp 还没有宏。每次,任何不能用函数来定义或是用特殊操作符来完成的事情都不得不通过手写来实现,这带来了很大的不便。不幸的是,这个公司的程序员们虽然杰出但却非常懒惰。在他们的程序中,当需要编写大量单调乏味的代码时,他们往往会写下一个注释来描述想要在该位置上编写的代码。更不幸的是,由于很懒惰,他们也很讨厌回过头去实际编写那些注释所描述的代码。不久,这个公司就有了一大堆无人可以运行的程序,因为全都是代表着尚需编写的代码的注释。
In desperation, the big bosses hired a junior programmer, Mac, whose job was to find the notes, write the required code, and insert it into the program in place of the notes. Mac never ran the programs—they weren’t done yet, of course, so he couldn’t. But even if they had been completed, Mac wouldn’t have known what inputs to feed them. So he just wrote his code based on the contents of the notes and sent it back to the original programmer.
走投无路之下,老板雇用了一个初级程序员 Mac。他的工作就是找到这些注释,编写所需的代码,然后再将其替换掉程序中的注释。Mac 从未运行过这些程序——因为程序尚未完成,所以他当然运行不了。但就算这些程序完成了,Mac 也不知道该用怎样的输入来运行它们。因此,他只是基于注释的内容来编写他的代码,再将其发还给最初的程序员。
With Mac’s help, all the programs were soon completed, and the company made a ton of money selling them—so much money that the company could double the size of its programming staff. But for some reason no one thought to hire anyone to help Mac; soon he was single- handedly assisting several dozen programmers. To avoid spending all his time searching for notes in source code, Mac made a small modification to the compiler the programmers used. Thereafter, whenever the compiler hit a note, it would e-mail him the note and wait for him to e-mail back the replacement code. Unfortunately, even with this change, Mac had a hard time keeping up with the programmers. He worked as carefully as he could, but sometimes— especially when the notes weren’t clear—he would make mistakes.
The programmers noticed, however, that the more precisely they wrote their notes, the more likely it was that Mac would send back correct code. One day, one of the programmers, having a hard time describing in words the code he wanted, included in one of his notes a Lisp program that would generate the code he wanted. That was fine by Mac; he just ran the program and sent the result to the compiler.
不过程序员们注意到了,他们将注释写得越精确,Mac 就越有可能发回正确的代码。一天,一个花费大量时间用文字来描述他想要的代码未遂的程序员,在他的注释里写入了一个可以生成他想要的代码的 Lisp 程序。这对 Mac 来说很简单;他只需运行这个程序并将结果发给编译器就好了。
The next innovation came when a programmer put a note at the top of one of his programs containing a function definition and a comment that said, “Mac, don’t write any code here, but keep this function for later; I’m going to use it in some of my other notes.” Other notes in the same program said things such as, “Mac, replace this note with the result of running that other function with the symbols and as arguments.”
接下来又出现了一种创新。有一个程序员在他程序的开始处写了一段备注,其中含有一个函数定义以及另一个注释,该注释为:“Mac,不要在这里写任何代码,但要把这个函数留给以后使用,我将在我的其他一些注释里用到它。” 同一个程序里的还有如下这样描述的注释:“Mac,将这个注释替换成用符号 和 作为参数来运行上面提到的那个函数所得到的结果。”
这项技术在几天里就迅速流行起来,多数程序都含有数十个注释,它们定义了那些只被其他注释中的代码所使用的函数。为了使 Mac 更容易地辨别那些只含有定义而不必立即回复的注释,程序员们用一个标准 前缀来标记它们:“给 Mac 的定义,仅供阅读。”(Definition for Mac, Read Only.)由于程序员们仍然很懒惰,这个写法很快被简化成 “DEF.MAC. R/O”,接着又被简化为 “DEFMACRO”。
Pretty soon, there was no actual English left in the notes for Mac. All he did all day was read and respond to e-mails from the compiler containing DEFMACRO notes and calls to the functions defined in the DEFMACROs. Since the Lisp programs in the notes did all the real work, keeping up with the e-mails was no problem. Mac suddenly had a lot of time on his hands and would sit in his office daydreaming about white-sand beaches, clear blue ocean water, and drinks with little paper umbrellas in them.
不久以后,这些给 Mac 的注释中再没有实际可读的英语了。Mac 每天要做的事情就是阅读并反馈那些来自编译器的含有 DEFMACRO 注释的电子邮件以及调用那些 DEFMACRO 里所定义的函数。由于注释中的 Lisp 程序做了所有实际的工作,跟上这些电子邮件的进度完全没有问题。Mac 手头上突然有了大量时间,可以坐在他的办公室里做那些关于白色沙滩、蓝色海水和鸡尾酒的白日梦了。
Several months later the programmers realized nobody had seen Mac for quite some time. When they went to his office, they found a thin layer of dust over everything, a desk littered with travel brochures for various tropical locations, and the computer off. But the compiler still worked—how could it be? It turned out Mac had made one last change to the compiler: instead of e-mailing notes to Mac, the compiler now saved the functions defined by DEFMACRO notes and ran them when called for by the other notes. The programmers decided there was no reason to tell the big bosses Mac wasn’t coming to the office anymore. So to this day, Mac draws a salary and from time to time sends the programmers a postcard from one tropical locale or another.