Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Why foo ?

Options
  • 06-05-2007 11:48am
    #1
    Registered Users Posts: 4,276 ✭✭✭


    So something I've noticed during tutorial type stuff from books the methods or values are usually "Foo" no more hello world.

    Whats the story?


Comments

  • Registered Users Posts: 9,579 ✭✭✭Webmonkey


    DEFINITION - Just as economists sometimes use the term "widget" as the ultimate substitute for "something" that is being measured, programmers tend to use the term "foo" (pronounced FOO) as a universal substitute for something real when discussing ideas or presenting examples. Suppose you are defining a template for any group of programmers to follow when creating a new user command, you might specify that the syntax for the command should be in the form:
    Command foo (arg1, arg2)
    

    where the "foo" would mean "the name you give to this command." In other words, "foo" is a nonsense kind of placeholder for some value that will be provided when using this template to define a real command. (And the "arg1" and "arg2" are arguments or information you would define that would be passed along with the command.) Because "foo" has no rational meaning of its own and because "foo" is conventionally used as such a placeholder, the idea will be clear to any programmer.

    Foo or any such word used this way is formally known as a metasyntactic variable. Eric Raymond, probably the world's greatest authority on foo and other metasyntactic variables, also lists qux, waldo, fred, xyzzy, and thud among others that are occasionally used. Although foo is the canonical metasyntactic variable, Raymond notes that cultures outside the United States have their own preferences. Fred, barney, and wombat seem common in the U.K. Toto, tata, titi, and tutu reportedly are used by the French. Blarg and wibble are used in New Zealand.

    The origin of foo seems wrapped in the mists of time, but Raymond observes (and we remember) that in Bill Holman's comic strip of the 1930-50 era, Smokey Stover, the letters "FOO" commonly appeared, unexplained and as a kind of running gag, on license plates, in picture frames, and on the backs of sandwich board signs.

    Source: http://searchsmb.techtarget.com/sDefinition/0,,sid44_gci212139,00.html

    I've always wondered too :)


  • Registered Users Posts: 4,276 ✭✭✭damnyanks


    Ah, thought it was somehow linked to fool :)


  • Closed Accounts Posts: 4,943 ✭✭✭Mutant_Fruit


    Don't forget foo's closest friends, "bar" and "baz"!

    zim = foo(bar, baz)


  • Registered Users Posts: 1,481 ✭✭✭satchmo


    Because 'bar' always seems to appear near it, I always thought it was something to do with 'fubar', as in 'f****d up beyond all recognition'. Doesn't really make much sense though.


  • Registered Users Posts: 2,297 ✭✭✭Ri_Nollaig


    i heard it meant 'file or object' but cant remember where, guess it does make sence as its just used as a placeholder for... a file or object :)


  • Advertisement
  • Registered Users Posts: 21,264 ✭✭✭✭Hobbes


    satchmo wrote:
    Because 'bar' always seems to appear near it, I always thought it was something to do with 'fubar', as in 'f****d up beyond all recognition'. Doesn't really make much sense though.

    That is a military term IIRC, to basically tell the people on the other side of the radio that everything has gone pear shaped. You can also use SNAFU (Situation normal, all fuked up).

    AFAIK foo and bar comes from that to point out example methods/variables.

    [edit]
    appears to be a "Metasyntactic_variable".
    http://en.wikipedia.org/wiki/Metasyntactic_variable


  • Registered Users Posts: 1,481 ✭✭✭satchmo


    Hobbes wrote:
    That is a military term IIRC, to basically tell the people on the other side of the radio that everything has gone pear shaped. You can also use SNAFU (Situation normal, all fuked up).
    That's why I didn't think it made much sense...


  • Registered Users Posts: 37,485 ✭✭✭✭Khannie


    satchmo wrote:
    Because 'bar' always seems to appear near it, I always thought it was something to do with 'fubar', as in 'f****d up beyond all recognition'. Doesn't really make much sense though.


    This is my understanding of it.


  • Registered Users Posts: 2,931 ✭✭✭Ginger


    THis reminds of the cartoon with Looney toons running around trying to find the origins of ACME :)


Advertisement