+ 3

what is metasyntatic variable?

20th Sep 2016, 12:40 PM
Aditya
Aditya - avatar
3 Answers
+ 5
HI, here is the scientific definition of the term: metasyntactic variable: A metasyntactic variable is a placeholder name used in computer science, a word without meaning intended to be substituted by some objects pertaining to the context where it is used. The word foo as used in IETF Requests for Comments is a good example. Here is some uses in Python: Spam, ham, eggs: metasyntactic variables of Python If you look at Python tutorials and sample code, proposals for new language features, you'll see spam, eggs, gouda, etc. all over the place. Why? - Metasyntactic variables If you're writing some toy code that doesn't do anything (e.g., it just demonstrates some syntax), there are obviously no meaningful names to give the variables and types in that code. What you need are words that are obviously meaningless, and obviously placeholders for the meaningful names that you'd use in real code. Of course there are no such words (except maybe "um" and "like" and the like), so the programming community has to invent a few and use them by convention. These are called metasyntactic variables; Wikipedia explains why they're called that, and some of the history. In other languages, they're usually called foo, bar, baz, and qux. Python has its own unique set of metasyntactic variables, which are actual words, but words unlikely to appear in normal code. This has the advantage that the pattern can be extended in new ways and everyone will intuitively know what you mean. Except, of course, that you have to know the pattern. Spam, eggs, cheese, beans, toast, and ham Python is named after Monty Python, because Python's inventor, Guido van Rossum, is a big fan, like many computer geeks. "Spam" is one of Monty Python's most famous skits. Most of the words in the skit are the repetitive names of the heavily-spam-focused breakfast dishes on the menu, plus a group of Vikings singing a song about Spam. So, Python uses the ingredients of those dishes for its metasyntactic variables.
5th Oct 2016, 9:56 AM
Krasimir Vatchinsky
Krasimir Vatchinsky - avatar
8th Aug 2017, 6:50 AM
visph
visph - avatar
+ 2
continue from the main post..... Here's the menu: egg and bacon egg, sausage, and bacon egg and spam egg, bacon, and spam egg, bacon, sausage, and spam spam, bacon, sausage, and spam spam, egg, spam, spam, bacon, and spam spam, spam, spam, egg, and spam spam, spam, spam, spam, spam, spam, baked beans, spam, spam, spam, and spam lobster thermidor aux crevettes with a Mornay sauce, garnished with truffle paté, brandy, and a fried egg on top, and spam So, you can see where the standard metasyntactic variables in Python come from.
5th Oct 2016, 9:58 AM
Krasimir Vatchinsky
Krasimir Vatchinsky - avatar