Foobar本身是一个俚语或俗语,英文里叫做slang。
slang
a type of language that consists of words and phrases that are regarded as very informal, are more common in speech than writing, and are typically restricted to a particular context or group of people.
一种由被认为是非常非正式的单词或短语组成的语言类型,更常见于口语, 少见于书面语,通常仅限于特定的语境或人群。
Foobar的介绍如下:
术语foobar(/ˈfuːbɑːr/)在计算机编程或计算机相关文档中被用作元语法变量和占位符名称。它们被用来命名实体,如变量、函数和命令,其确切身份并不重要,只是为了展示一个概念。
The terms foobar (/ˈfuːbɑːr/) are used as metasyntactic variables and placeholder names in computer programming or computer-related documentation.[1] They have been used to name entities such as variables, functions, and commands whose exact identity is unimportant and serve only to demonstrate a concept.
Foobar有可能是对二战时期军事俚语FUBAR(Fucked Up Beyond All Recognition)的俏皮暗示,意思是事情搞得一团糟,都面目全非了。
或者是二战时美军里有的说法:Fouled(Fucked) up beyond all repair,表示情况或东西已经被搞坏了,没法挽救了。
Fouled up beyond all repair (FUBAR) is a slang term that originated and was popularized during World War II by American soldiers. The term means that a situation or object is so messed up that it is beyond being salvageable.
第一个已知的在编程背景下的印刷品使用出现在1965年的麻省理工学院的《技术工程新闻》中。在编程时使用foo通常归功于麻省理工学院的技术模型铁路俱乐部(TMRC),大约在1960年。
所以,我们经常在一些编程例子中看到foo,bar这些词汇用作函数或变量名。
参考: