English Language & Usage Stack Exchange is a question and answer site for linguists, etymologists, and serious English language enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

What is the meaning of pragmatic in this example?

Another C construct, the #pragma directive, is used to instruct the compiler to use pragmatic or implementation-dependent features. A most notable user of this directive is OpenMP.

According to online dictionary, pragmatic means:

Dealing with things sensibly and realistically in a way that is based on practical rather than theoretical considerations.

But I can't see how this explains the word in the example above.

share|improve this question

closed as off topic by Robusto, F'x, Cerberus, Mitch, kiamlaluno Jun 15 '11 at 13:02

Questions on English Language & Usage Stack Exchange are expected to relate to English language and usage within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

The definition at en.wiktionary.org/wiki/pragma makes an attempt at explaining this :) – aedia λ Jun 14 '11 at 18:19
Why is it called pragmatic? Is it related to its original meaning? – Tim Jun 14 '11 at 18:22
Though many here could most likely give rational answers to this question, strictly, I would say it is off-topic. – Grant Thomas Jun 14 '11 at 18:27
This is really a programming question; more specifically, it is a programming language-specific question. A pragma is a compiler directive, and I suspect that the example is using "pragmatic" in a non-standard, CS-specific way. – Robusto Jun 14 '11 at 18:33
Vote to reopen. If 'pragmatic' is a Term of Art in Computer Science, then that's a fact about English Language usage, even if the meaning of that Term of Art is a CS question. – cindi Oct 3 '11 at 13:46
up vote 4 down vote accepted

Someone with better knowledge of this directive might have a more specific answer, but I think the context answers the question you are asking:

...is used to instruct the compiler to use pragmatic or implementation-dependent features.

That is, "pragmatic" in this context means "implementation-dependent." A pragma directive gives the compiler directions on how to interact with a specific architecture, for instance. Pragmas are a means to accomplish something efficiently (in a practical or pragmatic way) that might have a better theoretical solution.

In contrast, "implementation-independent" features are the ideal (non-pragmatic) way to design code. By using "implementation-independent" features, the code is theoretically self-contained and universally interoperable. This theoretical ideal is difficult in practice because of the heterogeneity of platforms and the diversity of interface methods. Using a directive that allows you to adapt code directly to a specific implementation is a lot more practical than trying to design something that is generic enough to work with every implementation.

Wiktionary has an entry on pragmas that might shed some light.

share|improve this answer
Thanks! So how to understand "implementation-independent" as theoretic, i.e., non-pragmatic? – Tim Jun 14 '11 at 18:32
@Tim: Not necessarily. I would say that implementation-independent would be ideal, that's the contrast. – Grant Thomas Jun 14 '11 at 18:36
@Tim I edited my answer to incorporate implementation-independent features. Hope that clarifies things. – Kit Z. Fox Jun 14 '11 at 18:53

It's a matter of doing what you need to do (in practical terms) rather than what the C standard strictly allows you to do.

Suppose you want to put a very short delay into your code. You might write something like this:

    int i;

    for (i = 0; i < 100000; i++)

It looks nice and simple; just repeatedly increment a variable and then throw it away. The trouble is that a sensible optimiser will spot that this code does exactly nothing and throw the whole thing away, leaving you with no delay. You could switch the optimiser off when you run the compiler, but you don't want to do that because it makes the rest of your program larger and less efficient.

If you stick rigidly to the standard, you are a bit stuck at this point. You could put this snippet in a file of its own and compile it separately with the optimiser off. That would be a more theoretically satisfying answer, but it comes with maintenance nightmares, the overhead of an extra function call, and so on.

The pragmatic answer, if your compiler supports such a thing, is to stick

#pragma optimisation_off
/* code here */
#pragma optimisation_on

around the code you want left alone.

(The real answer is to declare i as volatile or better yet not to write delays with spin loops, but let's ignore that for the sake of example.)

share|improve this answer
Great example, Rhodri. I was thinking along these lines, but my C is about fifteen years rusty. – Kit Z. Fox Jun 14 '11 at 18:54

Not the answer you're looking for? Browse other questions tagged or ask your own question.