Talk:Directive (programming)

Use of Directives in web frameworks not mentioned?
Specifically the Angular web development framework uses the term "directives" for example at: https://www.w3schools.com/angular/angular_directives.asp and https://docs.angularjs.org/guide/directive From the angularjs.org directive page: What are Directives? At a high level, directives are markers on a DOM element (such as an attribute, element name, comment or CSS class) that tell AngularJS's HTML compiler ($compile) to attach a specified behavior to that DOM element (e.g. via event listeners), or even to transform the DOM element and its children.

AngularJS comes with a set of these directives built-in, like ngBind, ngModel, and ngClass. Much like you create controllers and services, you can create your own directives for AngularJS to use. When AngularJS bootstraps your application, the HTML compiler traverses the DOM matching directives against the DOM elements. Could this usage of directive be added to this page? — Preceding unsigned comment added by 68.189.76.162 (talk) 18:39, 27 September 2018 (UTC)

Compiler options are directives?
Answer is not on the article.

Only if they are embedded in the source code in my opinion.

I would say that directives should apply to options, pre and post processsing and apply to both the compilation and program language features (for example the manner that APPLY acts on a block of code.) DHorse1 (talk) 23:03, 10 January 2010 (UTC)

Merge with Preprocessor?
To vote Yes or Not, and justify.

Yes! I don't think I've ever heard directive, as a standalone word, being used for the preprocessor directives of e.g. cpp. (The GNU cpp man page talks about "an #if directive" and so on, but that's in a clear context.) JöG 21:27, 4 December 2006 (UTC)

Don't Care but... Came to this page from redirect from "Pragma". Only reference on this page for pragma is in relationship to Ada. I presume that word is now meant as a general purpose substitute for "directive" - but not sure. Pragma needs better definition of current use (for example see http://code.google.com/p/support/wiki/WikiSyntax ). Can be either on this page or on preprocessor page.66.31.75.203 (talk) 18:46, 20 January 2009 (UTC)frank_fen@go.com

No: languages like Delphi (and Turbo Pascal, never heard of significant comments), does not have a preprocessor but have compiler directives. Note that also in Delphi there are compiler directives (the {$ comments) and directives that are words that are sensitive in specific locations within source code, but not reserved (i.e. stdcall, overload) --Ldsandon (talk) 10:52, 10 April 2009 (UTC)

C: #pragma's scope?
If main.c: -- #include "foo.h"  /  #pragma OPTION_A  /  #include "bar.h" and "foo.h": -- #pragma OPTION_B

Will "bar.h" be compiled with OPTION_A, OPTION_B or neither?

And will "#ifdef FOO / #pragma BAR / #endif" set "#pragma BAR" if FOO is undef?

(C99 wasn't clear about this...) (84.231.106.61 (talk) 15:44, 16 September 2012 (UTC))

Directives are part of the language in many cases
The article claims Directives are not part of the grammar of a programming language, but in many assemblers the directives are part of the formal grammar. --Shmuel (Seymour J.) Metz Username:Chatul (talk) 16:12, 22 November 2021 (UTC)

Examples and sources?
Should there be examples of various types of directives with sources for the syntax?
 * Conditional compilation, e.g., AIF for assemblers in OS/360 ... z/OS, %IF for PL/I
 * Defining a macro, e.g., MACRO and MEND in HLASM
 * Defining compile-time variables, e.g. GBLC in HLASM
 * Iterating (repeating) code, e.g., the IRP pseudo-op in FAP
 * Setting compile-time variables, e.g., SETC in HLASM

These are off the top of my head; there are many languages and many types of directives for which examples might be given.

Shmuel (Seymour J.) Metz Username:Chatul (talk) 15:45, 14 October 2022 (UTC)