why bar and foo

H

Hans Schneider

Why use people here bar and foo so much?

I tried google, but I have only found what they are, not why they are used.

My teacher says bar and foo are bad words.

Why people use them?
 
R

Randy Howard

Why use people here bar and foo so much?

I tried google, but I have only found what they are, not why they are used.

My teacher says bar and foo are bad words.

Your teacher is confused.
Why people use them?

They are "generic" variable names, for examples where the actual
variable name doesn't really matter, only how they are used in a piece
of code.
 
K

Keith Thompson

Hans Schneider said:
Why use people here bar and foo so much?

I tried google, but I have only found what they are, not why they are used.

My teacher says bar and foo are bad words.

Why people use them?

This really isn't a C question, but:

http://www.catb.org/~esr/jargon/html/F/foo.html
http://www.catb.org/~esr/jargon/html/B/bar.html
http://www.catb.org/~esr/jargon/html/F/foobar.html

I don't know why your teacher thinks they're "bad" words. One
possible derivation does refer to a word that's considered vulgar, but
that's far enough from the modern usage that it shouldn't matter.

For further discussion, try alt.folklore.computers (but browse the
group and/or check their FAQ first).
 
R

Richard Heathfield

Hans Schneider said:
Why use people here bar and foo so much?

They are metasyntactic variables...
I tried google, but I have only found what they are, not why they are
used.

....and people use them mostly because they're shorter than
"whatchamacallit", "thingummybob", and "dubrey", and thus quicker to type.
My teacher says bar and foo are bad words.

Your teacher is mistaken. Does your teacher often make ex cathedra claims
without first doing a little basic research? If so, you probably need to
fire your teacher and hire a new one.
 
N

Nick Keighley

Hans Schneider said:


They are metasyntactic variables...


...and people use them mostly because they're shorter than
"whatchamacallit", "thingummybob", and "dubrey", and thus quicker to type.

I use pippo
 
S

Sjouke Burry

Richard said:
Nick Keighley said:


Which version, and for which platform?
Pippo from "Pippo the clown" ??
That platform os rather antique(~40 years)???
AND THIS IS OFF TOPIC SIR!!!!!!
 
M

Martien Verbruggen

Pippo from "Pippo the clown" ??

<ot> If this is Pipo de Clown (met Mamaloe, Dikke Deur en Klukkluk), who
used to be on Dutch TV when I was a kid, then you're misspelling it. You
better go and fix your code before it notices.</ot>

Martien
 
R

Remo D.

Why use people here bar and foo so much?
Actually is "Pippo" as in "Pippo, Pluto, Paperino, Topolino, Minnie,
Qui, Quo, Qua". The names of Disney characters in Italian.

In Italy everytime a temporary names is needed, "pippo" is used (also as
a file name: "pippo.zip", "pippo.c", "pippo.doc") then the others,
according personal tastes.
 
N

Nick Keighley

Actually is "Pippo" as in "Pippo, Pluto, Paperino, Topolino, Minnie,
Qui, Quo, Qua". The names of Disney characters in Italian.

In Italy everytime a temporary names is needed, "pippo" is used (also as
a file name: "pippo.zip", "pippo.c", "pippo.doc") then the others,
according personal tastes.

I have Italian collegues
 
M

Michal Nazarewicz

Hans Schneider said:
Why use people here bar and foo so much?

I tried google, but I have only found what they are, not why they are
used.

My teacher says bar and foo are bad words.

They are bad variable names if you use them in real code but for
documentations and examples they are fine and in fact better than
anything else because everyone is familiar with them.
Why people use them?

Why not? Besides, would you really want to coin some fancy name when you
write a 3-line example code in library documentation? I prefer using
foo, bar, baz, qux, quux and for numbers 42.
 
J

John Bode

Why use people here bar and foo so much?

Tradition. They're small and easy to type, and are generally only
used in example code that doesn't really *do* anything, but just
illustrates a particular concept. They're not inherently meaningful
names.

Personally, I use blah, blurga, and bletch, because they sound funny
to me.
I tried google, but I have only found what they are, not why they are used.

My teacher says bar and foo are bad words.

The acronym FUBAR stands for "fucked up beyond all reason", but it's
an open question whether foo and bar are derived from it. On their
own, though, they're no more bad words than blah or quux.
Why people use them?

Again, tradition. They're just generic variable names.
 
H

Hans Schneider

Richard said:
Hans Schneider said:


They are metasyntactic variables...


...and people use them mostly because they're shorter than
"whatchamacallit", "thingummybob", and "dubrey", and thus quicker to type.


Your teacher is mistaken. Does your teacher often make ex cathedra claims
without first doing a little basic research? If so, you probably need to
fire your teacher and hire a new one.

Variable names and function names should say what they do.

Bar is a function is graphics.h (draw rectangle).

foo says nothing (says my teacher).

What purpose have variables and functions that have metasyntactic purpose?
 
B

Ben Bacarisse

Hans Schneider said:
Variable names and function names should say what they do.
Bar is a function is graphics.h (draw rectangle).
foo says nothing (says my teacher).

Ah. Your teacher means that foo and bar are bad in real programs. I
agree. I don't think I've ever seen either one in a real program.
What purpose have variables and functions that have metasyntactic
purpose?

The point is to use them only when the meaning of the name would be a
distraction. In a perfect world every example would be a real one
with good meaningful variable names, but sometimes you just want to
show that you can't assign an array:

int foo[2], bar[2];
foo = bar; /* not allowed */

or that functions can be mutually recursive:

int foo(int x) { return x * bar(x - 1); }
int bar(int x) { return x > 0 ? foo(x / 2) : x; }

and so on. You use daft names only when a "better" name (and thus
it's meaning) would be distracting.
 
P

Peter Nilsson

Hans Schneider said:
Variable names and function names should say what they do.

What does x do in (a * x * x + b * x + c)?

Sometimes naming identifiers after their purpose can
actually make code confusing, e.g. faux amis.
Bar is a function is graphics.h (draw rectangle).

It may be in one library that has a graphics.h header.
foo says nothing (says my teacher).

What purpose have variables and functions that have
metasyntactic purpose?

In pedagogic examples they serve to indicate that some
identifiers are incidental, and the reader should focus
on the example's main purpose.
 
H

Hans Schneider

Ben said:
Hans Schneider said:
What purpose have variables and functions that have metasyntactic
purpose?

The point is to use them only when the meaning of the name would be a
distraction. In a perfect world every example would be a real one
with good meaningful variable names, but sometimes you just want to
show that you can't assign an array:

int foo[2], bar[2];
foo = bar; /* not allowed */

Yes, but what about using in real programs.

For example, the program from John J. Smith in the roman number thread.

It is > 100% unreadable!
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top