Directive (programming): Difference between revisions

Content deleted Content added
top: undo removal of the word "or" - no one calls them "directive pragmas", it's one word or the other
Other languages: Haskell pragmas are entirely standard
Line 32:
* 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>.
* The [[Glasgow Haskell Compiler]], the most commonly used [[Haskell (programming language)|Haskell]] compiler,pragmas supportsare pragmasspecified suchusing a specialized comment syntax, ase.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|accessdate=18 July 2014}}</ref>
* [[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.