• In
Ada, compiler directives are called
pragmas (short for "pragmatic information"). • In
Common Lisp, directives are called
declarations, and are specified using the declare construct (also proclaim or declaim). With one exception, declarations are optional, and do not affect the semantics of the program. The one exception is special, 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
comments. 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 #include "file" directive is the significant comment {$I "file"}. • In
Perl, the
keyword "use", which imports modules, can also be used to specify directives, such as use strict; or use utf8;. •
Haskell pragmas are specified using a specialized comment syntax, e.g. {-# INLINE foo #-}. It is also possible to use the C preprocessor in Haskell, by writing {-# LANGUAGE CPP #-}. •
PHP uses the directive declare(strict_types=1). • In
PL/I, directives begin with a
Percent sign (%) and end with a semicolon (;), e.g., %INCLUDE
foo;, %NOPRINT;, %PAGE;, %POP;, %SKIP;, the same as with preprocessor statements. •
Python has two directives – from __future__ import feature (defined in PEP 236 -- Back to the __future__), which changes language features (and uses the existing module import syntax, as in Perl), and the coding directive (in a comment) to specify the encoding of a
source code file (defined in PEP 263 -- Defining Python Source Code Encodings). A more general directive statement was proposed and rejected in PEP 244 -- The `directive' statement; these all date to 2001. •
ECMAScript also adopts the use syntax for directives, with the difference that pragmas are declared as string literals (e.g. "use strict";, or "use asm";), rather than a function call. • In
Visual Basic, the keyword "Option" is used for directives: • Option Explicit On|Off - When on disallows implicit declaration of variables at first use requiring explicit declaration beforehand. • Option Compare Binary - 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 , ), the Select Case block, and VB
runtime library string functions (e.g. InStr). • Option Compare Text - 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) , ), the Select Case block, and VB runtime library string functions (e.g. InStr). • Option Strict On|Off - 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). • Option Infer On|Off - When on enables the compiler to infer the type of local variables from their initializers. • In
Ruby, interpreter directives are referred to as
pragmas and are specified by top-of-file comments that follow a key: value notation. For example, coding: UTF-8 indicates that the file is encoded via the
UTF-8 character encoding. • In
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 #pragma, which is specifically used to control compiler warnings and debugger checksums. C# also features some directives not used in C or C++, including #nullable and #region. 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. • In
Solidity, compiler directives are called pragmas, and are specified using the `pragma` keyword.
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, define and change assembly-time variables, define macros, designate conditional and repeated code, define reserved memory areas, and so on. Some, 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 .END, 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". ==See also==