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

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

1. Joona I PalasteGuest

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."

Joona I Palaste, Sep 7, 2003

2. Irrwahn GrausewitzGuest

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

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

Irrwahn

[1] No, this this is *not* a metasyntactic variable!

Irrwahn Grausewitz, Sep 7, 2003

3. gooseGuest

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
4. Steve ZimmermanGuest

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
5. Sheldon SimmsGuest

Why not "furz" and "luder"?

Sheldon Simms, Sep 7, 2003
6. Bruno DesthuilliersGuest

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
7. Tom ZychGuest

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

Tom Zych, Sep 7, 2003
8. Irrwahn GrausewitzGuest

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
9. Randy HowardGuest

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
10. ArWeGodGuest

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
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;
}

{
++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
11. Martin AmbuhlGuest

ArWeGod wrote:

What's wrong?! How dare you post code in which main has a return type of

Martin Ambuhl, Sep 9, 2003
12. Bruno DesthuilliersGuest

<troll>
because real programmers like to be arcane and chose these names
to be cutesy...
</troll>

Bruno

Bruno Desthuilliers, Sep 9, 2003
13. Dan PopGuest

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
14. Richard HeathfieldGuest

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
15. ArWeGodGuest

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
16. The Real OS/2 GuyGuest

wrong. use the dictionary
http://dict.tu-chemnitz.de/

The Real OS/2 Guy, Sep 11, 2003
17. Irrwahn GrausewitzGuest

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.

language. Thanks.

Irrwahn

Irrwahn Grausewitz, Sep 11, 2003
18. The Real OS/2 GuyGuest

====
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
19. Irrwahn GrausewitzGuest

^^^^^^^^^^^ ^^^^^^^^^^^
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
20. Jirka KlaueGuest

"Roedeln" is not uncommon in German, even if some random dictionaries