foo、bar、baz等的含义

Meaning of foo, bar, baz, etc

我一直想知道 foo、bar、baz 等... 名称的含义。

我曾多次在科学文章中发现这些术语。此外,该术语在某种程度上可作为其他示例的标准。

有谁知道这些术语的来源以及如何正确使用它们?

虽然这个问题超出了 Stack Overflow 的范围,但我强烈推荐关于这个问题的维基百科文章:

The History of Foobar

快速预览:

The word foo originated as a nonsense word from the 1930s, the military term FUBAR emerged in the 1940s... The term foo fighter was used by Allied aircraft pilots in World War II to describe various UFOs or mysterious aerial phenomena. The first known use of the terms in print in a programming context appears in a 1965 edition of MIT's Tech Engineering News.

The terms foobar (/ˈfuːbɑːr/), foo, bar, baz, and others are used as metasyntactic variables and placeholder names in computer programming or computer-related documentation. 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 Wikipedia article

总而言之,foo、bar 和其他术语用作占位符名称来演示一个概念。在现实生活中,这些值通常被替换为更有意义的名称,这些名称适合代码的上下文。