[OT] Variations of "foo", "bar", etc.

Discussion in 'C Programming' started by Joona I Palaste, Sep 7, 2003.

  1. Am I the only person here to sometimes use different metasyntactic
    variables than "foo", "bar", etc.? Here are some I use.

    two variables: yin, yang
    three variables: father, son, holy_ghost <or> athos, porthos, aramis
    four variables: om, mane, padme, hum

    --
    /-- Joona Palaste () ---------------------------\
    | Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
    | http://www.helsinki.fi/~palaste W++ B OP+ |
    \----------------------------------------- Finland rules! ------------/
    "It sure is cool having money and chicks."
    - Beavis and Butt-head
     
    Joona I Palaste, Sep 7, 2003
    #1
    1. Advertisements

  2. Personally, I like "farz" and "roedel".

    Some people use "oogle", "foogle", "boogle", etc.

    For others, try Google[1]:
    http://www.google.com/search?q=jargon+metasyntactic+variable

    Irrwahn

    [1] No, this this is *not* a metasyntactic variable! :)
     
    Irrwahn Grausewitz, Sep 7, 2003
    #2
    1. Advertisements

  3. Joona I Palaste

    goose Guest

    one, two, three, four ...

    only gets cumbersome if you reach *ties ->twenty_seven, fifty_one

    goose,
    "two = one + three / four" becomes a problem
     
    goose, Sep 7, 2003
    #3
  4. Joona,

    Thank you for the cool idea.

    --Steve

    ################# Experiment 1 (enum with switch-case) ####################

    #include <stdio.h>

    int main()
    {
    enum Tekel {
    RAND_VAR_1, RAND_VAR_2, RAND_VAR_3, RAND_VAR_4
    } upharsin;

    int u_element;

    printf("Enter upharsin element (or negative number to quit): ");
    scanf("%d", &u_element);

    while (u_element >= 0) {

    switch (u_element) {
    case RAND_VAR_1: printf("rapti_1\n");
    break;
    case RAND_VAR_2: printf("duorum_2\n");
    break;
    case RAND_VAR_3: printf("legati_3\n");
    break;
    case RAND_VAR_4: printf("Germanicum_4\n");
    break;
    default: fprintf(stderr, "Input error\n");
    break;
    }

    printf("Enter upharsin element (or negative number to quit): ");
    scanf("%d", &u_element);

    }

    return 0;
    }

    Input from keyboard: 0
    Output to screen: rapti_1

    Input from keyboard: 1
    Output to screen: duorum_2

    Input from keyboard: 2
    Output to screen: legati_3

    Input from keyboard: 3
    Output to screen: Germanicum_4

    Input from keyboard: 4
    Output to screen: Input error

    Input from keyboard: -1
    [bash:\> ~/clang/clc/enum_case]$


    EOX ###################################################################
     
    Steve Zimmerman, Sep 7, 2003
    #4
  5. Why not "furz" and "luder"?
     
    Sheldon Simms, Sep 7, 2003
    #5
  6. Somewhat mystical, isn't it ? (well... except for the references to Mr
    Dumas 's heroes...)

    In France, we are many to use toto, tata, titi, tutu... (note that all
    those words have a meaning in french).

    Bruno
     
    Bruno Desthuilliers, Sep 7, 2003
    #6
  7. Joona I Palaste

    Tom Zych Guest

    Someone I knew used to use names like "zebra" and "aardvark" for
    function names. Except, it wasn't for MSV's. It was in production
    code :p
     
    Tom Zych, Sep 7, 2003
    #7
  8. The latter are actually meaningful (german) words; the former,
    AFAIK, don't mean anything in any language (feel free to correct
    me on this).
     
    Irrwahn Grausewitz, Sep 7, 2003
    #8
  9. Joona I Palaste

    Randy Howard Guest

    I think that a check for "metasyntactic variable" at the Jargon File
    (any of the mirrors) on the web will show quite a few in common
    use.

    I've used, "foo", "bar" and "fred" for a long time. (Supposedly "Fred"
    is more common among British developers, but the fact that it is
    ridiculously easy to type is the reason I gravitated to it. If forced
    to add a fourth, I'd use "mary", with no good reason why.
     
    Randy Howard, Sep 9, 2003
    #9
  10. Joona I Palaste

    ArWeGod Guest

    Well, actually, I'm against this practice. I don't see why a reasonable name
    can't be used. I think programmers like to be arcane and chose these names
    to be cutesy. I don't have a lot of time to try to figure out examples with
    such names. I had never even thought about it until I read a letter in Dr.
    Dobb's Journal stating what I just said.

    Now those articles the letter writer was talking about were generally real
    code used in example to a real situation. I can see where you might have a
    function SO abstract that foo, bar, baz, etc. might be used. But an example
    is supposed to explain something, so why are we making harder to understand?

    Compare this to the following:

    void foo (void)
    {
    int baz;
    baz = bar (baz);
    }

    int bar (int tuti)
    {
    ++tuti;
    return (tuti);
    }

    What's wrong with something like this instead:

    void main (void)
    {
    int i;
    i = addone (i);
    }

    int addone (int input)
    {
    ++input;
    return (input);
    }

    Flame-prevention statement: I am not saying, "What's wrong with this code".
    OK? It an example of an example. Don't correct the code, please. Try to grok
    the message, which is, "Why not use real names for variables?"
     
    ArWeGod, Sep 9, 2003
    #10
  11. ArWeGod wrote:

    What's wrong?! How dare you post code in which main has a return type of
    'void' and ask "what's wrong"?
     
    Martin Ambuhl, Sep 9, 2003
    #11
  12. <troll>
    because real programmers like to be arcane and chose these names
    to be cutesy...
    </troll>

    Bruno
     
    Bruno Desthuilliers, Sep 9, 2003
    #12
  13. Joona I Palaste

    Dan Pop Guest

    These names are typically used in contexts where no name is more
    reasonable than another. So, instead of inventing some arbitrary name,
    it's faster to resort to the popular generic names.
    Being devoid of any meaning, they are ideal as generic identifiers.
    You have chosen a bad example, the function bar actually performing
    a meaningful operation. Quite often, this is not the case. Example:

    int foo(void) { puts("foo"); return 1; }
    int bar(void) { puts("bar"); return 1; }
    int baz(void) { puts("baz"); return 1; }
    ...
    foo() + bar() + baz();

    is commonly used to point out that the actual order in which foo, bar and
    baz are called is unspecified.

    Dan
     
    Dan Pop, Sep 9, 2003
    #13
  14. It /is/ a reasonable name, which illustrates very clearly and elegantly that
    the choice of name was not significant.
    It's easier to understand an example if you can easily tell which bits are
    there merely to satisfy the syntax, and which bits are supposed to be
    exegetic. Hence the value of foo.
    The first void.
     
    Richard Heathfield, Sep 9, 2003
    #14
  15. Joona I Palaste

    ArWeGod Guest

    Everyone,

    The OP was asking for opinions. I gave mine. Give yours and shut up. I don't
    care what you think, I was telling the OP what I think. Talk to the Mouse.

    Dan,

    You've restated my case, but in the negative. Let me start again.

    In many example programs, the sample actually _does_ something. Yet, the
    writer chooses to use the time-honoured foo, bar, etc. names. I find that
    the example programs are NOT meaningless examples. This could be a flaw in
    the author to come up with a generic but syntactically (sp?) correct
    program, or whatever. It just usually ends up being something from their own
    experience and has a function (if you will). For instance many Dr. Dobbs
    Journal articles, where the examples are more "real - world" than some
    posts; often an actual meaningful variable or function name would get the
    point across, but they use meaningless terms. It's as if they want to "fit -
    in" and be kewl. It tends to detract from the article, IMHO, and in the
    opinion of the author of letter I am describing that changed my thinking.

    I have no problem using foo, etc. if the example is TOTALLY generic. I just
    don't see it much..

    Flame ON!
     
    ArWeGod, Sep 10, 2003
    #15
  16. wrong. use the dictionary
    http://dict.tu-chemnitz.de/
     
    The Real OS/2 Guy, Sep 11, 2003
    #16
  17. I did so:

    - No match for "farz" in either german or english dict
    - No match for "roedel" in either german or english dict

    Maybe the words have a meaning in some other language I
    and the mentioned dictionary do not know of.

    I suggest /you/ use a dictonary before telling others to do so.

    And, please, stop telling me nonsense, at least about my native
    language. Thanks.

    Irrwahn
     
    Irrwahn Grausewitz, Sep 11, 2003
    #17
  18. ====
    I'd answerd the quote you'd quoted. Nobody can think you means
    anything above the quote you'd written the answer under.
    I'd done so, really, both word underlined are transated well.
     
    The Real OS/2 Guy, Sep 11, 2003
    #18
  19. ^^^^^^^^^^^ ^^^^^^^^^^^
    Do you know the meaning of the words 'latter' and 'former'? See below.
    Then don't respond to *my* comment starting off with 'wrong ... ',
    for C's sake!!!!
    *Nobody* doubted, and if you reread ///carefully/// you will notice
    that we both agree that 'furz' and 'luder' are, albeit not nice,
    german words!!!
     
    Irrwahn Grausewitz, Sep 11, 2003
    #19
  20. Joona I Palaste

    Jirka Klaue Guest

    "Roedeln" is not uncommon in German, even if some random dictionaries
    don't know about it. ;-)

    Jirka
     
    Jirka Klaue, Sep 12, 2003
    #20
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.