`
acrbb
  • 浏览: 11693 次
  • 性别: Icon_minigender_1
  • 来自: 上海
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

为什么有那么多的例子程序使用foo和bar作为函数名?

阅读更多

http://mail.python.org/pipermail/tutor/2000-March/001266.html

python.orgDennis E. Hamilton 解释了原因:

Great question!

I can’t remember when I first saw foo and bar used in examples.  It was a
long time ago.  I have this sense that it was quite popular around MIT and
maybe even the DEC crowd and in the Multics community.  It is typically used
in composing file names in code examples about file processing.  There is
also a potential pun, from the days when connections to files had funny
names, like A01, C05, F00 (those are zeroes).

It is a mild joke.  There is an old US military acronym, FUBAR (other
military organizations will have their own versions).  In the context of
Python it means something like "Friendlied Up Beyond All Recognition".  Cf.
RTFM.  Once you’ve seen it, it becomes difficult not to use it.  The
continued use of it is for the same reason that it was used in the first
place:  "Where can I get some easy, meaningless file names to use in an
example?"  It’s easier than inventing new names.  And it is automatic.  And
there is tacit knowledge of it in the community, like recognizing a recuring
character in your favorite series of novels.

I’d be amazed if FOO and BAR are *not* mentioned in the Hackers Dictionary.

I’m grateful that you asked.  It reminds us of how much is taken for granted
that, for a neophyte, is not easily distinguished as having material or only
incidental importance.   With the wonderful international nature of
computing today, it is an important challenge for those of us who are
already "in the know" to provide clarity and simplicity.

– Dennis

0
2
分享到:
评论

相关推荐

    在名字空间中声明类和成员函数定义.pdf

    例如,在下面的例子中,我们定义了一个名为proj_alpha的名字空间,它包含类Spy、函数encrypt和常量MAX_SPIES: namespace proj_alpha { class Spy {/*..*/}; void encrypt (char *msg); const int MAX_SPIES = 8...

    makefile详解 使用变量和函数

    在上面的例子中,我们定义了三个变量“foo”、“bar”和“ugh”,然后在使用“foo”时,Makefile 会自动展开变量的值。 第二种方式是使用“:=”操作符,例如: ``` x := foo y := $(x) bar x := later ``` 在上面的...

    通配符 校验 C语言 函数库

    在IT领域,通配符和校验是两个重要的概念,特别是在文本处理和文件搜索中。通配符是一种特殊的字符或符号,用于代表一个或...理解和掌握如何在C语言中使用通配符和函数库,能帮助开发者编写更加灵活和强大的应用程序。

    重载函数的理解

    1. **函数名相同**:所有被重载的函数都必须具有相同的名字。 2. **参数列表不同**: - 参数个数不同 - 参数类型不同 - 参数顺序不同 - 参数的类型不同包括: - 基本类型不同,如`int`与`char`。 - 有符号类型...

    Python 基础课程《16.函数使用进阶》

    闭包通常在函数的嵌套定义和函数名作为返回值的基础上实现。 **闭包的应用实例 1:** ```python def func2(): n = 0 def func1(): nonlocal n n = n + 1 print("第%d次执行" % n) return func1 f = func2()...

    makefile的变量用法

    使用大写字母作为变量名是以前的习惯,但我们推荐在Makefile内部使用小写字母作为变量名,预留大写字母作为控制隐含规则参数或用户重载命令选项参数的变量名。 变量引用基础写一个美元符号后跟用圆括号或大括号括住...

    预处理及程序运行过程.pdf

    这样定义后,`CONCAT(foo, bar)`会被替换为`foobar`。 #### 1.4 宏的副作用 宏的文本替换特性有时会导致副作用。例如: ```c #define MAX(a, b) ((a > b) ? a : b) int x = 5, y = 10; int z = MAX(x++, y); ``` 在...

    详解JavaScript中的函数声明和函数表达式

    这段代码声明了一个名为 `foo` 的函数,这个函数没有参数,也没有返回值。需要注意的是,在JavaScript的预处理阶段,函数声明会被提升到当前作用域的顶部,这就是所谓的变量提升(hoisting)。 函数表达式则是将...

    jQuery插件开发

    调用时,使用`$.myPlugin.foo()`和`$.myPlugin.bar('baz')`。 #### 对象级别的插件开发 对象级别的插件开发则是在jQuery对象上添加新的方法。这种方式通常用于创建具有特定功能的插件,比如DOM操作或动画效果。 *...

    前端开源库-path-complete-extname

    `path-complete-extname` 是一个开源库,专为处理和解析文件路径中的扩展名而设计,尤其是在面对包含多个点(.)的扩展名时。这个库是对Node.js内置的`path.extname`函数的一个增强,提供了更全面的支持。 `path....

    C语言中的三大定律

    C语言中的三大定律 ...在上面的例子中,数组名`a`被当作指针使用,函数内部可以通过指针来访问数组元素。 C语言中的三大定律是学习C语言的基础,理解这些定律可以帮助开发者更好地编写C语言程序。

    freemarker总结

    上面的代码中的逻辑表达式用括号括起来主要是因为里面有>符号,由于FreeMarker会将>符号当成标签的结束字符,可能导致程序出错,为了避免这种情况,我们应该在凡是出现这些符号的地方都使用括号. Pythons are ...

    How+to+Write+makefile.pdf

    例如,在上面的例子中,如果删除 `foo.o` 和 `bar.o` 的依赖项定义,`make` 仍然能够正确地构建它们,因为它知道 `.c` 文件应该被编译成 `.o` 文件。 #### 伪目标 伪目标是在 Makefile 中定义的目标,但不是实际的...

    xml创建,用XDocument来写的

    在这个例子中,“RootElement”被定义为根元素,其下有两个“ChildElement”,每个“ChildElement”都具有两个属性:“Attribute1”和“Attribute2”。 3. **构建XML元素和属性**:使用XElement和XAttribute类来...

    Make 使用与makefile的编写

    ### Make 使用与makefile的编写 #### 一、Make 概述 - **make** 是一个自动化构建工具,主要用于组织和执行编译任务。 - **makefile** 是make的指令文件,它描述了如何构建软件项目的各个部分。 #### 二、...

    java面向对象考题和答案.doc

    由于 `Bar` 类覆盖了 `addFive()` 方法,并且在方法体中使用 `this.a`,这意味着该方法将会改变 `Bar` 类中定义的 `a` 成员变量,而不是 `Foo` 类中的 `a`。`Bar` 类的 `a` 初始化为 8,经过 `addFive()` 方法调用后...

    PHP基础教程 是一个比较有价值的PHP新手教程!

    不过明确的是编写那样的代码有多简单,购买它们会有多昂贵以及它们需要多么昂贵和强大的硬件。如果你有什么中立的观点(比如说没有被SUN和Microsoft的百万美金所影响),请顺便通知我。 据我所知,JSP基于Java,...

Global site tag (gtag.js) - Google Analytics