Talk:Directive (programming)
![]() | This article is rated C-class on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||
|
Use of Directives in web frameworks not mentioned?
[edit]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: <quote>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.</quote> 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?
[edit]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?
[edit]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)[email protected]
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?
[edit]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
[edit]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?
[edit]Should there be examples of various types of directives with sources for the syntax?
- Conditional compilation, e.g., AIF[1] 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[2] 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.
References
- ^ "AIF instruction" (PDF). High Level Assembler for z/OS & z/VM & z/VSE (PDF). IBM. pp. 396–398. SC26-4940-08. Retrieved October 14, 2022.
{{cite book}}
:|work=
ignored (help) - ^ "The IRP Pseudo-Operation" (PDF). IBM 7090/7094 Programming Systems - FORTRAN II Assembly Program (FAP) (PDF). IBM. p. 50. GC28-6235-5. Retrieved October 14, 2022.
{{cite book}}
:|work=
ignored (help)
Shmuel (Seymour J.) Metz Username:Chatul (talk) 15:45, 14 October 2022 (UTC)