So I know what pragma is, and what it's used for, but what is the meaning of the word itself? I've used it many times in code, but I never really knew what the word actually means or stands for.
-
13It has roots in the Greek term πραγμα, which is the root of "pragmatic". That's the best I can tell you. – asveikau Sep 24 '10 at 21:51
-
6+1 I've always wondered this but for some reason never thought to ask here. – Jay Riggs Sep 24 '10 at 21:52
-
1Hmmm... what's the root of the word "wonder"? Can we have a etymology overflow, please? – Sep 24 '10 at 21:55
-
24@AaronMcSmooth How is this off topic? It's programming related. – Firoso Sep 24 '10 at 21:55
-
1@Firoso, how does knowing the answer to this make you a better programmer? What's the etymology of the word 'function'? wOOt!! Now I know and I can write better functions. (not) I'm not saying that it's not interesting, just that it doesn't belong here. – aaronasterling Sep 24 '10 at 21:57
-
7Hey, folks, pragmas are programming-related. Fair 'nuff to wonder where the term comes from and ask your peers in professional software development, isn't it? – T.J. Crowder Sep 24 '10 at 21:57
-
6@AaronMcSmooth, read the FAQ, this doesn't qualify as off topic. Also does knowing who Ada Lovelace was make you a better programmer? no? then why is she mentioned in every CS curriculum I'm aware of. – Firoso Sep 24 '10 at 22:09
-
2Asking about the meaning and/or lineage of a word is not programming-related just because that word happens to be used in programming. That's what [dictionaries](http://dictionary.reference.com/browse/pragma) are for, not SO. – gnovice Sep 24 '10 at 22:37
-
3Knowing the natural-language origin of a programming keyword is akin to being fluent in the natural-language from which a programming language draws keywords. E.g., wouldn't you be a slightly better programmer if you knew English and could be clued in quicker to the intent behind "continue", "return", etc? – Jon-Eric Sep 25 '10 at 00:06
-
2Then again, I could argue that being well rounded and having hobbies also makes you a better programmer. And I wouldn't want questions about your garden here. – Jon-Eric Sep 25 '10 at 00:13
-
3@Firoso: 'Cause CS curricula are written by academics who (as a class) are concerned about priority and the proper apportionment of credit and generally keeping certain names around? On top of which she's one of a fairly small set of big *female* names from the early days, which is of some importance these days, too. – dmckee --- ex-moderator kitten Sep 25 '10 at 03:33
-
2@gnovice: He's not asking about non-programming uses of a programming word, but the history in the context of programming. E.g. "Why does C call them 'functions'?" vs. "Someone said 'the function of a motor is..', what is 'function'?" Perhaps the question text could be improved. – Sep 25 '10 at 05:14
-
http://www.etymonline.com/index.php?search=pragma – Jon Purdy Sep 25 '10 at 05:53
-
@Jon: No hits for pragma, just pragmatism and pragmatic. – Sep 25 '10 at 06:13
-
@Roger: I know. Just putting in my two cents and sharing a plug for a site I like. – Jon Purdy Sep 25 '10 at 06:15
-
2Didn't think this would cause such a stink, but thanks for the great answers everyone! – MGSoto Sep 27 '10 at 18:15
5 Answers
According to a US Government-owned(!) document describing the design of Ada: Rationale for the Design of the Ada® Programming Language :
A pragma (from the Greek word meaning action) is used to direct the actions of the compiler in particular ways, but has no effect on the semantics of a program (in general).
I like the (last caveat) there...
This cross references well with on-line greek dictionaries (e.g. as quoted by Martin York) that say pragma (πράγμα, as commented on the original question by asveikau) means:
- that which has been done, a deed, an accomplished fact
- what is done or being accomplished
- spec. business, a commercial transaction
- a matter, question, affair
- spec. in a forensic sense, a matter at law, case, suit
- that which is or exists, a thing
Seems the key to understanding is the word action rather than information.

- 1
- 1

- 76,436
- 32
- 213
- 198
In mathematics and logic, a pragma is a given, a fact, a prerequisite to the argument, problem, or proof which follows.

- 2,124
- 14
- 13
Pulled right from Wikipedia(programming):
In Ada, compiler directives are called pragmas (short for "pragmatic information").
While it's not explicitly for C, this should answer your question anyway. However, as T.J. pointed out, there is no valid source given for this piece of information.

- 1,031,962
- 187
- 1,923
- 1,875

- 5,179
- 2
- 38
- 52
-
8Mind, that article doesn't cite *any* original sources...and searching on A Famous Web Search Engine for "+pragma +pragmatic +ada" turns up a very, very short list of clearly non-canonical sites. Doesn't mean it's not true. – T.J. Crowder Sep 24 '10 at 21:54
-
1You're absolutely right, a source would be most appreciated. Still, I guess it's best to leave the answer unless I'm proven wrong. – Philipp Schlösser Sep 24 '10 at 22:06
From the ancient Greek:
pragma: a thing done, a fact
As with all things geeky, somebody was trying to be way too clever for their own good. Unfortunately its original meaning becomes lost to the rest of us (unless you have Google and a Latin/Greek to English dictionary handy).
http://www.studylight.org/lex/grk/view.cgi?number=4229
http://www.bibletools.org/index.cfm/fuseaction/Lexicon.show/ID/G4229/pragma.htm
Original (that is what the above page says, but I don't have a copy of that book):
Thayer and Smith. "Greek Lexicon entry for Pragma". "The New Testament Greek Lexicon".

- 2,336
- 5
- 31
- 40

- 257,169
- 86
- 333
- 562
The programming language Ada was quite possibly the first compiler to use pragma to specify preprocessor directives. The word was used as a shortened form of "pragmatic information"
When the C programming language was designed it didn't initially have pragma directives, but was quickly added to the specification to support custom compiler features. (ie. #pragma optimization_level for the intel C++ compiler)
Since then many languages have implemented pragma in some form or another, including C#, but they are often limited to build time warnings and optimization hints.
One of the most common and useful pragmas, in non-standard C and C++, is #pragma once used to specify that a file should only be included once.

- 24,359
- 19
- 83
- 121

- 6,647
- 10
- 45
- 91