Directive (programming): Difference between revisions

Content deleted Content added
identity,cybercrime,defamation,targeting,misrepresentation,theft,copyright,fraud,hatered promoters !
Tags: Reverted Mobile edit Mobile app edit iOS app edit
 
(32 intermediate revisions by 23 users not shown)
Line 1:
{{short description|Language construct that specifies how a compiler should process its input}}
{{Refimprove|date=December 2013}}
In [[computer programming]], a '''directive''' or '''pragma''' (from "pragmatic") is a [[language construct]] that specifies how a [[compiler]] (or other [[Translator (computing)|translator]]) should process its input. DirectivesDepending areon the [[programming language]], directives may or may not be part of the [[Formal grammar|grammar]] of a [[programmingthe language]], and may vary from compiler to compiler. They can be processed by a [[preprocessor]] to specify compiler behavior, or function as a form of [[In-band signaling|in-band]] parameterization.
 
In some cases directives specify global behavior, while in other cases they only affect a local section, such as a block of programming code. In some cases, such as some C programs, directives are optional compiler hints, and may be ignored, but normally they are prescriptive, and must be followed. However, a directive does not perform any action in the language itself, but rather only a change in the behavior of the compiler.
 
This term could be used to refer to proprietary third -party tags and commands (or markup) embedded in code that result in additional executable processing that extend the existing compiler, assembler and language constructs present in the development environment. The term "directive" is also applied in a variety of ways that are similar to the term ''command''.
 
==The C preprocessor==
Line 10 ⟶ 11:
 
In [[C (programming language)|C]] and [[C++]], the language supports a simple [[Macro (computer science)|macro]] [[preprocessor]]. Source lines that should be handled by the preprocessor, such as <code>#define</code> and <code>#include</code> are referred to as ''preprocessor directives''.
 
Another C construct, the <code>#pragma</code> directive, is used to instruct the compiler to use pragmatic or implementation-dependent features. Two notable users of this directive are [[OpenMP]] and [[OpenACC]].
 
Syntactic constructs similar to C's preprocessor directives, such as [[C Sharp (programming language)|C#]]'s <code>#if</code>, are also typically called "directives", although in these cases there may not be any real preprocessing phase involved.
 
All preprocessor commands, except for <code>defined</code> (when following a conditional directive), begin with a hash symbol (#). Until [[C++26]], the keywords <code>export</code>, <code>import</code> and <code>module</code> were partially handled by the preprocessor.<ref>{{cite web|url=https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1857r1.html|title=P1857R1 - Modules Dependency Discovery}}</ref>
All preprocessor commands begin with a hash symbol (#).
 
==History==
Directives date to [[JOVIAL]].<ref>{{cite tech report
Directives date to [[ALGOL 68]], where they are known as [[ALGOL 68#pr .26 co: Pragmats and Comments|pragmats]] (from "pragmatic"), and denoted '''pragmat''' or '''pr'''; in newer languages, notably C, this has been abbreviated to "pragma" (no 't').
| title = Computer Programming Manual for JOVIAL (J73) Language
| id = RADC-TR-81-143
| date = June 1981
| section = Chapter 17 - Directives
| section-url = https://apps.dtic.mil/sti/pdfs/ADA101061.pdf#page=248
| pages = 243-263
| url = https://apps.dtic.mil/sti/pdfs/ADA101061.pdf
| access-date = May 28, 2023
}}
</ref>
<!-- Replace with an older online version if not behind a paywall -->
 
[[COBOL]] has a COPY directive.
A common use of pragmats in ALGOL 68 is in specifying a [[Stropping (syntax)|stropping]] regime, meaning "how keywords are indicated". Various such directives follow, specifying the POINT, UPPER, RES (reserved), or quote regimes. Note the use of stropping for the '''pragmat''' keyword itself (abbreviated '''pr'''), either in the POINT or quote regimes:
.PR POINT .PR
.PR UPPER .PR
.PR RES .PR
'pr' quote 'pr'
 
DirectivesIn date to [[ALGOL 68]], where theydirectives are known as [[ALGOL 68#pr .26 co: Pragmats and Comments|pragmats]] (from "pragmatic"), and denoted '''pragmat''' or '''pr'''; in newer languages, notably C, this has been abbreviated to "pragma" (no 't').
 
A common use of pragmats in ALGOL 68 is in specifying a [[Stropping (syntax)|stropping]] regime, meaning "how keywords are indicated". Various such directives follow, specifying the POINT, UPPER, RES (reserved), or quote regimes. Note the use of stropping for the '''pragmat''' keyword itself (abbreviated '''pr'''), either in the POINT or quote regimes:
{{sxhl|2=man|1=
.PR POINT .PR
.PR UPPER .PR
.PR RES .PR
'pr' quote 'pr'
}}
Today directives are best known in the C language, of early 1970s vintage, and continued through the current [[C99]] standard, where they are either instructions to the [[C preprocessor]], or, in the form of <code>#pragma</code>, directives to the compiler itself. They are also used to some degree in more modern languages; see below.
 
Line 33 ⟶ 48:
* In [[Turbo Pascal]], directives are called '''significant comments''', because in the language [[grammar]] they follow the same syntax as [[comment (computer programming)|comment]]s. In Turbo Pascal, a significant comment is a comment whose first character is a [[dollar sign]] and whose second character is a letter; for example, the equivalent of C's <code>#include "file"</code> directive is the significant comment <code>{$I "file"}</code>.
* In [[Perl]], the [[keyword (computer programming)|keyword]] "<code>[http://perldoc.perl.org/functions/use.html use]</code>", which imports modules, can also be used to specify directives, such as <code>use strict;</code> or <code>use utf8;</code>.
* [[Haskell (programming language)|Haskell]] pragmas are specified using a specialized comment syntax, e.g. <code>{-# INLINE foo #-}</code>.<ref>{{cite web|title=7.20. Pragmas|url=http://www.haskell.org/ghc/docs/7.8.3/html/users_guide/pragmas.html|website=GHC 7.8.3 Documentation|access-date=18 July 2014}}</ref> It is also possible to use the C preprocessor in Haskell, by writing <syntaxhighlight lang="Haskell" inline>{-# LANGUAGE CPP #-}</syntaxhighlight>.
* [[PHP]] uses the directive <code>declare(strict_types=1)</code>.
* In [[PL/I]], directives begin with a [[Percent sign]] (<code>%</code>) and end with a semicolon (<code>;</code>), e.g., <code>%INCLUDE ''foo'';</code>, <code>%NOPRINT;</code>, <code>%PAGE;</code>, <code>%POP;</code>, <code>%SKIP;</code>, the same as with preprocessor statements.
* [[Python (programming language)|Python]] has two directives – <code>from __future__ import feature</code> (defined in [https://www.python.org/dev/peps/pep-0236/ PEP 236 -- Back to the __future__]), which changes language features (and uses the existing module import syntax, as in Perl), and the <code>coding</code> directive (in a comment) to specify the encoding of a source code file (defined in [https://www.python.org/dev/peps/pep-0263/ PEP 263 -- Defining Python Source Code Encodings]). A more general directive statement was proposed and rejected in [https://www.python.org/dev/peps/pep-0244/ PEP 244 -- The `directive' statement]; these all date to 2001.
* [[ECMAScript]] also adopts the <code>use</code> syntax for directives, with the difference that pragmas are declared as string literals (e.g. <code>"use strict";</code>, or <code>"use asm";</code>), rather than a function call.
Line 46 ⟶ 63:
** <code>Option Infer On|Off</code> - When on enables the compiler to infer the type of local variables from their initializers.
* In [[Ruby (programming language)|Ruby]], interpreter directives are referred to as '''pragmas''' and are specified by top-of-file comments that follow a <code>key: value</code> notation. For example, <code>coding: UTF-8</code> indicates that the file is encoded via the [[UTF-8]] [[character encoding]].
* In [[C Sharp (programming language)|C#]], compiler directives are called pre-processing directives. C# does not technically handle these using a preprocessor, but rather directly in the code. There are a number of different compiler directives, which mostly align with those from C and C++, including <code>#pragma</code>, which is specifically used to control compiler warnings and debugger checksums.<ref>{{Cite web|url=https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure|title=Lexical structure - C# language specification|last=dotnet-bot|website=docs.microsoft.com|language=en-us|access-date=2019-11-01}}</ref><ref>{{Cite web|url=https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives/preprocessor-pragma|title=#pragma - C# Reference|last=BillWagner|website=docs.microsoft.com|language=en-us|access-date=2019-11-01}}</ref> C# also features some directives not used in C or C++, including <code>#nullable</code> and <code>#region</code>. C# also does not allow function-like macros, but does allow regular macros, for purposes such as conditional compilation.
* The [[SQLite]] [[DBMS]] includes a PRAGMA directive that is used to introduce commands that are not compatible with other DBMS.<ref>{{cite web |title=Pragma statements supported by SQLite |url=https://www.sqlite.org/pragma.html |website=www.sqlite.org}}</ref>
* In [[Solidity]], compiler directives are called pragmas, and are specified using the `pragma` keyword.<ref>{{Cite web |title=Layout of a Solidity Source File — Solidity 0.8.27 documentation |url=https://docs.soliditylang.org/en/latest/layout-of-source-files.html#pragmas |access-date=2024-06-03 |website=docs.soliditylang.org}}</ref>
 
===Assembly language===
* In [[assembly language]], directives, also referred to as pseudo-operations or "pseudo-ops", generally specify such information as the target machine, mark separations between code sections, invokedefine and change assembly-time variables, define macros, designate conditional and repeated code, define reserved memory areas, and so on. AssemblersSome, but not all, assemblers use a specific syntax to differentiate pseudo-ops from instruction mnemonics, such as prefacing the pseudo-op with a period, such as the pseudo-op <code>.END</code>, which might direct the assembler to stop assembling code.
<!-- Should there be examples? -->
 
===PL/SQL===
Line 61 ⟶ 80:
| first2 = Bill
| title = Oracle PL/SQL Programming
| date = 23 January 2014
| url = https://books.google.com/books?id=vQaoAgAAQBAJ
| edition = 6
Line 74 ⟶ 94:
* {{annotated link|pragma once|#pragma once}}
 
==Footnotes==
disclaimer of any organisation, business , immoveable property, vehicle, loan , credit,___domain,website,internetservice , subscription , game , or whatsoever holding me as the title owner of any product or service provider under my identity .
notice for reporting of documents related to my identity such as passport copy , driving license copy , college id copy .
disclosure of fact of being of 27 years age as ov 07.09.1993 .
report of misuse of internet services being ny developers , i never hired any developer to work for me .
reference to defamation of person being made through media kit services and other applications of apple ios .
reference to facebook and google accounts bearing my name and any other social media platform as of now ! due to the reason of breach to my identity and misrepresentation and fraud .
i have suspicion on 2 partners who have been exploiting the public and infringing my privacy .
for privacy notice kindly refer to department of homeland security dated 10.3.2021 , and copy of FIR in delhi .
my outlook account and gmail account have been compromised as well .
my devices have been set up as if i am a minor but im 27 .
i dont operate for any company or any agreement on contractual terms making so .
i am specially targeted by such people because of personal reason to be unknown and the same person is himself full of sins but just has money so has set up all these services and account subscriptions decieving my social image .
my life , peace and security is to be at threat because in the past 10 years i have not caused harm to any person .
i am a student and researcher of LAW .
kindly dispute any false claims made to be as me unless it is physically confirmed .
i am willing to protect my rights but some people have so much time that they cant report it to claim damages but create a misconception about me in public ___domain .
i am a target of being bullied , harrassment,ad targeting and other types of information provided through network services .
people who personally know me about the kind of person i am wont say that he would not hurt anyone else . as i do not because i know what it feels to be hurt .
i hope we all stay healthy, safe and at peace . and god bless the ones who are unfortunate victims .
please like and support
AMEN .
==References==
{{Refimprove|date=December 2013}}
{{reflist}}
 
==References==
{{refbegin}}
* {{cite book | isbn = 1-55558-041-6 | title = [[Common Lisp the Language]] | last = Steele | first = Guy L. | author-link = Guy L. Steele | year = 1990 | publisher = Digital Press | pages = 215–237 }}