Why do examples use foo
The word foo is the canonical example. In filenames, a common convention is that any filename beginning with a metasyntactic-variable name is a scratch file that may be deleted at any time. To some extent, the list of one's preferred metasyntactic variables is a cultural signature.
They occur both in series used for related groups of variables or objects and as singletons. Here are a few common signatures:. At MIT but not at Stanford , baz dropped out of use for a while in the s and '80s. A common recent mutation of this sequence inserts qux before quux. Other CMU-associated variables include gorp. These are the first words a child used to learn to spell on a Dutch spelling board.
Of all these, only 'foo' and 'bar' are universal and baz nearly so. Some jargon terms are also used as metasyntactic names; barf and mumble, for example. See also Commonwealth Hackish for discussion of numerous metasyntactic variables found in Great Britain and the Commonwealth.
Wikipedia gives this definition of Metasyntactic Variable :. In computer science, programmers use metasyntactic variables to describe a placeholder name or an alias term commonly used to denote the subject matter under discussion or an arbitrary member of a class of things under discussion.
The use of a metasyntactic variable is helpful in freeing a programmer from creating a logically named variable, which is often useful when creating or teaching examples of an algorithm. The word foo is the principal example.
The term "metasyntactic variable" is primarily found in informal literature. It is sometimes also used as a synonym for metavariable. Any symbol or word which does not violate the rules of the language can be used as a metasyntactic variable, but nonsense words are commonly used. The same concept is employed in other fields where it is expressed by terms such as schematic variable see logical form. By mathematical analogy: A metasyntactic variable is a word that is a variable for other words, just as in algebra letters are used as variables for numbers.
C In the following example of the C programming language the function name foo and the variable name bar are both metasyntactic variables. Spam, ham, and eggs are the principal metasyntactic variables used in the Python programming language.
In the following example the baz, foo, and bar are metasyntactic variables and lines beginning with are comments. The terms foobar, foo, bar, and baz, are common placeholder names also referred to as metasyntactic variables used in computer programming or computer-related documentation. They are commonly used to represent unknown values, typically when describing a scenario where the purpose of the unknown values are understood, but their precise values are arbitrary and unimportant.
The terms can be used to represent any part of a complicated system or idea, including the data, variables, functions, and commands. The words themselves have no meaning in this usage, and are merely logical representations, much like the letters x and y are used in algebra. Foobar is often used alone; foo, bar, and baz are usually used in that order, when multiple entities are needed. Foo has entered the English language as a neologism and is considered by many to be the canonical example of a metasyntactic variable.
Eric S. Raymond has called it an "important hackerism" alongside kludge and cruft. Early versions of the Jargon File [JARGON] interpreted this change as a post-war bowdlerization, but it now seems more likely that FUBAR was itself a derivative of 'foo' perhaps influenced by German 'furchtbar' terrible - 'foobar' may actually have been the original form.
For, it seems, the word 'foo' itself had an immediate prewar history in comic strips and cartoons. Many of these people were in MIT's Tech Model Railroad Club, where we find the first documented use of "foo" in tech circles in and a variant in Both "foo" and "bar" and even "baz" were well known in popular culture, especially from Smokey Stover and Pogo comics, which will have been read by many TMRC members.
The use of lone "foo" as a nonsense word is pretty well documented in popular culture in the early 20th century, as is the military FUBAR. The Lounger thinks that this business of Foo-ism has been carried too far by its misguided proponents, and does hereby and forthwith take his stand against its abuse. It may be that there's no foo like an old foo, and we're it, but anyway, a foo and his money are some party.
Voice from the bleachers- "Don't be foo-lish! As an expletive, of course, "foo! We say alas because proper use of the word may result in such happy incidents as the following. It was an 8. The professor, having covered the front side of the blackboard, set the handle that operates the lift mechanism, turning meanwhile to the class to continue his discussion.
The front board slowly, majestically, lifted itself, revealing the board behind it, and on that board, writ large, the symbols that spelled "FOO"!
The Tech newspaper , a year earlier, the Letter to the Editor, September :. By the time the train has reached the station the neophytes are so filled with the stories of the glory of Phi Omicron Omicron, usually referred to as Foo, that they are easy prey.
It is not that I mind having lost my first four sons to the Grand and Universal Brotherhood of Phi Omicron Omicron, but I do wish that my fifth son, my baby, should at least be warned in advance. And The Tech in December :. General trend of thought might be best interpreted from the remarks made at the end of the ballots.
One vote said, '"I don't think what I do is any of Pulver's business," while another merely added a curt "Foo. Our first obligation is to keep the Foo Counters turning. The dictionary's compiler Pete Samson said in Use of this word at TMRC antedates my coming there. A foo counter could simply have randomly flashing lights, or could be a real counter with an obscure input. And from 's Jargon File 4. Earlier versions of this lexicon derived 'baz' as a Stanford corruption of bar.
He says "It came from "Pogo". Albert the Alligator, when vexed or outraged, would shout 'Bazz Fazz! Further research under a joint Foocom and Anarcom grant expanded the law to be all embracing and universally applicable: If anything can go wrong, it will! But let's remember this question is about code examples, so let's find "foo", "bar" and "foobar" published in code.
So, Jargon File 4. Hart and Michael Levin:. Walter Mitty recalled on this site in I second the jargon file regarding Foo Bar. John V. Everett recalls in When I joined DEC in , foobar was already being commonly used as a throw-away file name. Since the x was also a 36 bit machine, foobar may have been used as a common file name there.
Foo and bar were also commonly used as file extensions. Since the text editors of the day operated on an input file and produced an output file, it was common to edit from a. It was also common to use foo to fill a buffer when editing with TECO. Daniel P. Smith in Dick Gruen had a device in his dorm room, the usual assemblage of B-battery, resistors, capacitors, and NE-2 neon tubes, which he called a "foo counter.
Robert Schuldenfrei in This too may be older, but that is where I first saw it. This was in Assembler. Paul M. Wexelblat in The earliest PDP-1 Assembler used two characters for symbols 18 bit machine programmers always left a few words as patch space to fix problems.
Jump to patch space, do new code, jump back That space conventionally was named FU: which stood for Fxxx Up, the place where you fixed Fxxx Ups. When spoken, it was known as FU space. Later Assemblers e. Bruce B. Reynolds in I haven't been able to find any references to foo bar as "inverted foo signal" as suggested in RFC and elsewhere.
Atomic Energy Commission. For example:. If you are trying to explain a concept where the important part is not what is being done printing meow or bark for example but on how it is being done then removing the parts that you are familiar help:.
Now you have to focus on what is really happening, you are no longer able to guess at what is going to happen. So, the short version is, that foo, bar, and the like, are used to stress concepts where the content doesn't really matter but the idea does. Today, I avoid using "foo" and prefer using this type of named substitution for a couple of reasons. In my opinion every programmer has his or her own "words" that is used every time you need an arbitrary word when programming.
For some people it's the first words from a childs song, for other it's names and for other its something completely different. Now for the programmer community there are these "words" as well, and these words are 'foo' and 'bar'. The use of this is that if you have to communicate publicly about programming you don't have to say that you would use arbitratry words, you would simply write 'foo' or 'bar' and every programmer knows that this is just arbitrary words.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. What does 'foo' really mean? Asked 13 years, 2 months ago. Active 2 years, 10 months ago. Viewed k times. Glorfindel The question linked in the previous comment has apparently been deleted. It is still available in the unofficial archive of deleted questions: stackoverflow.
Active Oldest Votes. Quoting only the relevant definitions from that RFC for brevity: Used very generally as a sample name for absolutely anything, esp. First on the standard list of metasyntactic variables used in syntax examples bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, thud.
Community Bot 1 1 1 silver badge. Oh that's just awesome. They have an RFC for Foo. Mark Tomlin, look at the date in that RFC. What is a RFC ;-? They have since become the official record for Internet specifications, protocols, procedures, and events". Show 2 more comments.
Will Harris Will Harris Add a comment. As definition of "Foo" has lot's of meanings: bar, and baz are often compounded together to make such words as foobar, barbaz, and foobaz. CodesInChaos k 22 22 gold badges silver badges bronze badges. Great answer but probably worth put a link to Jargon file entry: catb. Google results aren't an answer — nialljsmith.
So then what is answer? I think that stackoverflow must have things in one place, not just links to other sites, that's way i posted all this into one thread. Hey, if you're going to post all the non-programming related answers, why did you leave out "foo-fighter" the name WWII pilots gave to UFOs they saw and couldn't identify but presumed were enemy fighters?
Blorgbeard Blorgbeard It is used in place of an object variable or file name. Deathstalker Deathstalker 6 6 silver badges 6 6 bronze badges. I think it's meant to mean nothing. The wiki says: "Foo is commonly used with the metasyntactic variables bar and foobar. GateKiller GateKiller I like the comparison with other languages and their different meanings :-D — Matt. In my earlier days, I originally found the use of "foo" as a placement in any example to represent something as f'd-up to be confusing.
I wanted a working example, not something that was foobar. Jimmy B Jimmy B 31 2 2 bronze badges.
0コメント