Content deleted Content added
removed clarify template |
|||
Line 28:
==Other languages==
* In [[Ada (programming language)|Ada]], compiler directives are called '''pragmas''' (short for "pragmatic information").
* In [[Common Lisp]], directives are called '''declarations''', and are specified using the <code>declare</code> construct (also <code>proclaim</code> or <code>declaim</code>).{{sfn|Steele|1990|loc=[http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node103.html Chapter 9: Declarations], p. 215–237}} With one exception, declarations are optional, and do not affect the semantics of the program. The one exception is <code>special</code>, which must be specified where appropriate.▼
* 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 [[Common Lisp]], directives are called '''declarations''', and are specified using the <code>declare</code> construct (also <code>proclaim</code> or <code>declaim</code>).{{sfn|Steele|1990|loc=[http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node103.html Chapter 9: Declarations], p. 215–237}} With one exception, declarations are optional, and do not affect the semantics of the program. The one exception is <code>special</code>, which must be specified where appropriate.
* 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>.
* The [[Glasgow Haskell Compiler]], the most commonly used [[Haskell (programming language)|Haskell]] compiler, supports pragmas such as <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|accessdate=18 July 2014}}</ref>▼
▲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>.
* [[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.▼
*In [[Visual Basic]], the keyword "<code>Option</code>" is used for directives:▼
** <code>Option Explicit On|Off</code> - When on disallows implicit declaration of variables at first use requiring explicit declaration beforehand.
▲The [[Glasgow Haskell Compiler]], the most commonly used [[Haskell (programming language)|Haskell]] compiler, supports pragmas such as <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|accessdate=18 July 2014}}</ref>
** <code>Option Compare Binary</code> - Results in string comparisons based on a sort order derived from the internal binary representations of the characters - e.g. for the English/European code page (ANSI 1252) A < B < E < Z < a < b < e < z < À < Ê < Ø < à < ê < ø. Affects intrinsic operators (e.g. =, <>, <, >), the Select Case block, and VB runtime library string functions (e.g. InStr).▼
** <code>Option Compare Text</code> - Results in string comparisons based on a case-insensitive text sort order determined by your system's locale - e.g. for the English/European code page (ANSI 1252) (A=a) < (À = à) < (B=b) < (E=e) < (Ê = ê) < (Z=z) < (Ø = ø). Affects intrinsic operators (e.g. =, <>, <, >), the Select Case block, and VB runtime library string functions (e.g. InStr).▼
▲[[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.
** <code>Option Strict On|Off</code> - When on disallows:▼
*** typeless programming - where declarations which lack an explicit type are implicitly typed as Object.▼
*** late-binding (i.e. dynamic dispatch to CLR, DLR, and COM objects) on values statically typed as Object.▼
*** implicit narrowing conversions - requiring all conversions to narrower types (e.g. from Long to Integer, Object to String, Control to TextBox) be explicit in code using conversion operators (e.g. CInt, DirectCast, CType).▼
▲In [[Visual Basic]], the keyword "<code>Option</code>" is used for directives:
** <code>Option
▲* <code>Option Compare Binary</code> - Results in string comparisons based on a sort order derived from the internal binary representations of the characters - e.g. for the English/European code page (ANSI 1252) A < B < E < Z < a < b < e < z < À < Ê < Ø < à < ê < ø. Affects intrinsic operators (e.g. =, <>, <, >), the Select Case block, and VB runtime library string functions (e.g. InStr).
▲* <code>Option Compare Text</code> - Results in string comparisons based on a case-insensitive text sort order determined by your system's locale - e.g. for the English/European code page (ANSI 1252) (A=a) < (À = à) < (B=b) < (E=e) < (Ê = ê) < (Z=z) < (Ø = ø). Affects intrinsic operators (e.g. =, <>, <, >), the Select Case block, and VB runtime library string functions (e.g. InStr).
▲* <code>Option Strict On|Off</code> - When on disallows:
▲** typeless programming - where declarations which lack an explicit type are implicitly typed as Object.
▲** late-binding (i.e. dynamic dispatch to CLR, DLR, and COM objects) on values statically typed as Object.
▲** implicit narrowing conversions - requiring all conversions to narrower types (e.g. from Long to Integer, Object to String, Control to TextBox) be explicit in code using conversion operators (e.g. CInt, DirectCast, CType).
===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, invoke macros, define reserved memory areas, and so on. 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.
===PL/SQL===
* [[Oracle Corporation]]'s [[PL/SQL]] procedural language includes a set of compiler directives, known as "pragmas".<ref>
{{cite book
| last1 = Feuerstein
|