views:

802

answers:

5

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.

+10  A: 

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.

Phlibbo
Mind, 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
You're absolutely right, a source would be most appreciated. Still, I guess it's best to leave the answer unless I'm proven wrong.
Phlibbo
@Phlibbo: Absolutely.
T.J. Crowder
+4  A: 

from the ancient Greek:

pragma: a thing done, a fact

As with all things geeky. Somebody was trying to be way to 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".

Martin York
+3  A: 

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 is #pragma once used to specify that a file should only be included once.

Firoso
+13  A: 

In mathematics and logic, a pragma is a given, a fact, a prerequisite to the argument, problem, or proof which follows.

CuriousRabbit
+1 Looks like the maths boys know there history stuff better than us CS guys.
Martin York
ITYM their history.
Marius Gedminas
+19  A: 

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:

  1. that which has been done, a deed, an accomplished fact
  2. what is done or being accomplished
    1. spec. business, a commercial transaction
  3. a matter, question, affair
    1. spec. in a forensic sense, a matter at law, case, suit
  4. that which is or exists, a thing

Seems the key to understanding is the word action rather than information.

martin clayton
Great answer, a very good reference and summary of its contents. Thanks!
MGSoto