English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

2007-10-18 01:20:02 · 7 answers · asked by lasith100 2 in Computers & Internet Programming & Design

7 answers

Its a metasyntactic variable. You are not supposed to use "foo" itself but to replace it with an appropriate variable name in your own program. In UNIX circles, it just became popular as a short example variable to illustrate how a program is used.

2007-10-18 01:32:19 · answer #1 · answered by Runa 7 · 1 2

about the origins of foo and bar (Foobar):

The word "foobar" may be derived from the WW II era Army slang acronym FUBAR (`F**d Up Beyond All Repair'), later modified to foobar and carried back by returning GIs to morph into other uses. In technology, the word was probably originally propagated through DECsystem manuals by Digital Equipment Corporation or DEC in 1960s and early 1970s. Another possibility is that foobar evolved from electronics, as an inverted foo signal. This is because a digital signal is active low (so a negative or zero-voltage condition represents a "1") then a horizontal bar is commonly placed over the signal label[1]. The Jargon File makes a reasonably good case that foo predates fubar. It is also possible that these two come from physics.[citation needed]

2007-10-18 09:36:18 · answer #2 · answered by cruppstahl 4 · 1 0

I first noticed the use of "foo" in text books where the author want to call attention to a section of code. This distinguishes the code in question from other commonly used variable names like X,Y & Z. Using foo is easy as you don't have to think of a relavent name for the variable to fit the usage of your example code.

I don't know exactly when this started being used but it seems to have come into vouge with the past 10 years or so along with "Hello World"

2007-10-18 08:37:41 · answer #3 · answered by MarkG 7 · 2 1

People don't (and shouldn't) use foo as a variable name in real code. This name is used for example code like in a tutorial and usually as a function name rather than variable to indicate that it is a custom and not standard lib function. In code, people use descriptive names.

2007-10-18 08:28:39 · answer #4 · answered by Anonymous · 2 2

the answer is the same with the answer for the question;

"why my algebra teacher uses 'x', 'y', and 'z' as variables names?"

2007-10-18 08:49:02 · answer #5 · answered by Anonymous · 1 2

just like many use "i" as a variable in a loop...

2007-10-18 08:29:03 · answer #6 · answered by CLOUND 3 · 1 2

They just dont want people to know the real name for safety reasons,because they are hiding from there opponent or their ememy.

2007-10-18 08:32:02 · answer #7 · answered by Anonymous · 0 7

fedest.com, questions and answers