Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do other languages use things like Foo, Bar; Spam, Eggs

In languages like Java, Javascript, C, C++, C#, I have seen code similar to the folowing in tutorials and code snippets.

int foo = 5;
int bar = 10;
baz(foo, bar);

I assume these are used for quick variable names when naming conventions do not really need to be followed, such as quick snippets, but they have become so popular, they seem to be part of the language. For example, python has traded foo and bar for spam and eggs.

spam = 'spam'
eggs = 'eggs'
spam_and_eggs(spam, eggs)

When I see these variable names, I instantly think of python and no other language. Do other languages have signature placeholder variable names such as python?

like image 817
Brian Tracy Avatar asked Apr 10 '14 02:04

Brian Tracy


1 Answers

These variables aren't generally part of the languages at all, they're called meta-syntactic variables and allow you to use variables in example code without having to think too hard about what it should be called.

I tend to use something similar, calling all my source files qq.c or qq.py (for example) when testing one-shot code for Stack Overflow.

The Jargon file lists a decent variety of these (including their likely etymology) but, unfortunately, fail to list my personal favorites, xyzzy, plugh, twisty and passages, in order of preference and use, and showing my age :-)

like image 157
paxdiablo Avatar answered Oct 01 '22 21:10

paxdiablo