Pragmatic directives: Difference between revisions

m
(Pragmatic directives en QBasic)
 
(12 intermediate revisions by 8 users not shown)
Line 17:
* <code>ifdef</code>/<code>ifndef</code>/<code>else</code>/<code>endif</code>: The assembler will skip anything inside an IFDEF block if the designated label wasn't defined. IFNDEF and ELSE are the opposite. To make an IFDEF statement true, you only need to have that label defined in your source. (The value doesn't matter as long as it appears.) Here's an example:
 
<langsyntaxhighlight lang="6502asm">NMOS_6502 equ 1
ifdef NMOS_6502
txa
Line 23:
else
phx ;NMOS_6502 doesn't have this instruction.
endif ; every ifdef/ifndef needs an endif</langsyntaxhighlight>
 
* <code>db</code>/<code>dw</code>/<code>byte</code>/<code>word</code>: Defines a data block. The assembler treats these values as arbitrary bytes rather than machine instructions. Used for tables of values, etc.
Line 74:
{{works with|ALGOL 68G|Any - tested with release [http://sourceforge.net/projects/algol68/files/algol68g/algol68g-2.3.5 algol68g-2.3.5] - most compiler directives are permitted as '''pragma'''s options - also ' '''pr''' read "filename.a68" '''pr''' ' is permitted to "include" a file.}}
{{wont work with|ELLA ALGOL 68|Any (with appropriate job cards) - tested with release [http://sourceforge.net/projects/algol68/files/algol68toc/algol68toc-1.8.8d/algol68toc-1.8-8d.fc9.i386.rpm/download 1.8-8d] - due to implementation specific PRAGMA.}}
'''File: Pragmatic_directives.a68'''<langsyntaxhighlight lang="algol68">#!/usr/local/bin/a68g --script #
 
PRAGMAT portcheck PRAGMAT
Line 85:
PROC (REAL)REAL s = sin();
 
SKIP</langsyntaxhighlight>'''Output:'''
<pre>
10 PROC (REAL)REAL s = sin();
Line 99:
{{works with|GWBASIC}}
 
<langsyntaxhighlight lang="basic">10 TRON: REM activate system trace pragma
20 TROFF: REM deactivate system trace pragma</langsyntaxhighlight>
'''
'''
 
==={{header|IS-BASIC}}===
<langsyntaxhighlight ISlang="is-BASICbasic">TRACE ON
TRACE OFF</langsyntaxhighlight>
 
==={{header|QBasic}}===
<langsyntaxhighlight lang="qbasic">TRON : REM activate system trace pragma
TROFF : REM deactivate system trace pragma
REM QBasic debugging features make these instructions unnecessary
END</langsyntaxhighlight>
 
 
=={{header|C}}==
The C Preprocessor is well explained on the [https://gcc.gnu.org/onlinedocs/cpp/index.html#Top GNU] site. The pragma page is [https://gcc.gnu.org/onlinedocs/cpp/Pragmas.html here].
<syntaxhighlight lang="c">
<lang C>
/*Almost every C program has the below line,
the #include preprocessor directive is used to
Line 157:
 
/*Enlightened ?*/
</syntaxhighlight>
</lang>
On compilation and output, the compiler type is detected rather than the actual OS :
<pre>
Line 196:
 
Above would check for the COCOA feature and if not present, load the library. The library is also expected to later push the feature COCOA to the features list. Reading this code then later would ignore the require statement.
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|}}
Delphi has dozens of directive that change the way the compiler and the language work.
 
Here is a link describing the way directive work in general:
 
[https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Delphi_compiler_directives Using Delphi Directives]
 
Here is a list of all the directive available in current versions of Delphi:
 
https://docwiki.embarcadero.com/RADStudio/Sydney/en/Delphi_Compiler_Directives_(List)_Index
 
<syntaxhighlight lang="Delphi">
// Some examples
 
{$R *.dfm}
 
{$R WorldMaps.res}
 
{$optimization on,hints off}
 
{$B+}
{$R- Turn off range checking}
{$I TYPES.INC}
{$M 32768,40960}
{$DEFINE Debug}
{$IFDEF Debug}
{$ENDIF}
 
 
procedure DivMod(Dividend: Cardinal; Divisor: Word;
var Result, Remainder: Word);
{$IFDEF PUREPASCAL}
begin
Result := Dividend div Divisor;
Remainder := Dividend mod Divisor;
end;
{$ELSE !PUREPASCAL}
{$IFDEF X86ASM}
asm // StackAlignSafe
PUSH EBX
MOV EBX,EDX
MOV EDX,EAX
SHR EDX,16
DIV BX
MOV EBX,Remainder
MOV [ECX],AX
MOV [EBX],DX
POP EBX
end;
{$ENDIF X86ASM}
{$ENDIF !PUREPASCAL}
 
 
 
</syntaxhighlight>
{{out}}
<pre>
 
</pre>
 
 
=={{header|D}}==
Line 242 ⟶ 305:
 
Additionally, parsing words sometimes alter compiler behavior. For example, the compiler uses type information from <code>TYPED:</code> words for optimizations.
=={{header|FreeBASIC}}==
FreeBASIC does not have pragmatic directives in the traditional sense.
However, it has several built-in keywords and functions that can affect program behavior in a similar way to pragmatic directives in other languages.
 
Thus, FreeBASIC has keywords such as <code>Public</code> and <code>Private</code> that can change the visibility of variables and functions within a module.
<syntaxhighlight lang="vbnet">Private Sub i_am_private
End Sub
 
Public Sub i_am_public
End Sub</syntaxhighlight>
 
 
It also has keywords like <code>CDecl</code>, <code>Pascal</code> and <code>StdCall</code> that can change the calling convention of a function.
 
Cdecl is usually the default calling convention for C compilers and is used almost exclusively on Unix, Linux, *BSD, and DOS-like systems.
<syntaxhighlight lang="vbnet">' declaring 'strcpy' from the standard C library
Declare Function strcpy Cdecl Alias "strcpy" (Byval dest As ZString Ptr, Byval src As ZString Ptr) As ZString Ptr</syntaxhighlight>
 
Pascal is the default calling convention for procedures in Microsoft QuickBASIC and is the standard convention used in the Windows 3.1 API.
<syntaxhighlight lang="vbnet">Declare Function MyFunctionPascal Pascal Alias "MyFunction" (param As Integer) As Integer</syntaxhighlight>
 
Stdcall is the default calling convention on Windows and the most common in BASIC languages and the Windows API.
<syntaxhighlight lang="vbnet">Declare Function MyFunc1 Stdcall (param1 As Integer, param2 As Integer) As Integer</syntaxhighlight>
 
=={{header|Go}}==
Go has a feature called [http://golang.org/pkg/go/build/#overview build constraints] that work on the level of whole files. A comment line reading
 
<syntaxhighlight lang ="go">// +build <expression></langsyntaxhighlight>
 
will cause the entire file to be excluded from a build unless <expression> is true. The elements, called tags, in the expression are typically things like the target operating system or hardware architecture. For example
 
<syntaxhighlight lang ="go">// +build linux</langsyntaxhighlight>
 
will include the file if the target OS is linux, but will exclude the file otherwise. Arbitrary tags can be passed on the command line of the go command. A file could begin
 
<syntaxhighlight lang ="go">// +build Tuesday</langsyntaxhighlight>
 
and the build command
 
<langsyntaxhighlight lang="bash">go install -tags `date +%A`</langsyntaxhighlight>
 
would only include the file on Tuesdays.
Line 264 ⟶ 350:
=={{header|Icon}} and {{header|Unicon}}==
Icon and Unicon have a number of pragmatic modes. Most of these are controlled via keywords (See [[Special_variables#Icon_and_Unicon]])).
<langsyntaxhighlight Iconlang="icon">&trace # controls execution tracing
&error # controls error handling</langsyntaxhighlight>
 
Additionally, tracing can be controlled via the environment variable 'TRACE'.
Line 299 ⟶ 385:
For example,
 
<syntaxhighlight lang ="j"> 9!:25]1</langsyntaxhighlight>
 
disables access to the file system (and disables some other features, including the ability to exit the program, because the system exit mechanism is a system feature and thus not trusted). You cannot turn this off after it has been turned on (so you will need to shut down J and start it again if you want to use those features).
Line 305 ⟶ 391:
Or, for example, y is the usual name for the right argument of a verb.
 
<langsyntaxhighlight lang="j"> 3 :'y' 8
8</langsyntaxhighlight>
 
But y is also a regular variable. So J also offers a reserved word y. which serves the same role. But this is disabled by default (because mostly it's just an unnecessary complication).
 
<langsyntaxhighlight lang="j"> 3 :'y.' 8
|spelling error</langsyntaxhighlight>
 
But you can enable the reserved word mechanism:
 
<langsyntaxhighlight lang="j"> 9!:49]1
3 :'y.' 8
8
Line 321 ⟶ 407:
8
3 :'y.]y=.7' 8
7</langsyntaxhighlight>
 
=={{header|Java}}==
The closest things which Java has to pragmatic directives are annotations which begin with the @ character.
<syntaxhighlight lang="java">
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public final class PragmaticDirectives {
public static void main(String[] aArgs) {
/* Take no action */
}
@FunctionalInterface
public interface Adder { // This annotation indicates a functional interface,
abstract int add(int a, int b); // which has exactly one abstract method.
}
@Deprecated
public void Display() {
System.out.println("This author is indicating that this method is deprecated");
}
@SuppressWarnings("unchecked")
public void uncheckedWarning() {
List words = new ArrayList();
words.add("hello");
System.out.println("THe compiler is warning that the generic type declaration is missing.");
System.out.println("The correct syntax is: List<String> words = new ArrayList<String>()");
}
@SafeVarargs
public static <T> List<T> list(final T... items) {
System.out.println("This annotation suppresses unchecked warnings about a non-reifiable variable arity type");
return Arrays.asList(items);
}
}
</syntaxhighlight>
 
=={{header|Julia}}==
Julia has a number of macros which act as compiler directives. For example, the <code>@inbounds</code> macro disables runtime checking of array bounds within a block of code marked by this macro, which sometimes improves performance. Example:
<langsyntaxhighlight lang="julia">x = rand(100, 100)
y = rand(100, 100)
 
Line 336 ⟶ 462:
end
end
</syntaxhighlight>
</lang>
 
=={{header|Kotlin}}==
The closest things which Kotlin has to pragmatic directives are annotations which always begin with the @ character. For example, the following code would normally produce a compiler warning that the variable 's' is never used. However, the presence of the @Suppress annotation suppresses the warning:
<langsyntaxhighlight lang="scala">// version 1.0.6
 
@Suppress("UNUSED_VARIABLE")
Line 346 ⟶ 472:
fun main(args: Array<String>) {
val s = "To be suppressed"
}</langsyntaxhighlight>
 
=={{header|Lua}}==
Lua itself really doesn't have anything equivalent. However, if being used in a mixed/hosted/embedded environment, the <code>ffi</code> library might be encountered, which supports <code>pragma pack</code> to facilitate native type interchange:
<syntaxhighlight lang="lua">ffi = require("ffi")
ffi.cdef[[
#pragma pack(1)
typedef struct { char c; int i; } foo;
#pragma pack(4)
typedef struct { char c; int i; } bar;
]]
print(ffi.sizeof(ffi.new("foo")))
print(ffi.sizeof(ffi.new("bar")))</syntaxhighlight>
{{out}}
<pre>5
8</pre>
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
Line 356 ⟶ 497:
NetRexx provides three pragma-like instructions: <tt>OPTIONS</tt>, <tt>NUMERIC</tt> and <tt>TRACE</tt>.
* '''<tt>OPTIONS</tt>''' provides the ability to pass special requests to the language processor (i.e. a compiler or interpreter).
:The syntax is:<syntaxhighlight lang NetRexx="netrexx">options wordlist;</langsyntaxhighlight>
:where ''wordlist'' is one or more symbols separated by blanks. The individual words in ''wordlist'' might control optimizations, enforce standards, enable implementation-dependent features, etc.
:The current default settings of <tt>OPTIONS</tt> is:<langsyntaxhighlight NetRexxlang="netrexx">options -
nobinary nocomments nocompact console crossref decimal nodiag noexplicit noformat java logo noreplace nosavelog nosourcedir -
nostrictargs nostrictassign nostrictcase nostrictimport nostrictprops nostrictsignal nosymbols trace2 noutf8 verbose3</langsyntaxhighlight>
* '''<tt>NUMERIC</tt>''' is used to change the way in which arithmetic operations are carried out by a program.
:The syntax is:<langsyntaxhighlight NetRexxlang="netrexx">numeric digits [exprd];
numeric form [scientific | engineering];</langsyntaxhighlight>
:*'''<tt>numeric digits</tt>''' controls the precision under which arithmetic operations will be evaluated. The default for ''exprd'' is '''9''' i.e. '''<tt>numeric digits 9</tt>'''.<br />There is normally no limit to the value for <tt>'''numeric digits'''</tt> (except the constraints imposed by the amount of storage and other resources available) but note that high precisions are likely to be expensive in processing time.
:*'''<tt>numeric form</tt>''' controls which form of exponential notation is to be used for the results of operations.
* '''<tt>TRACE</tt>''' is used to control the tracing of the execution of NetRexx methods, and is primarily used for debugging.
:The Syntax is:<langsyntaxhighlight NetRexxlang="netrexx">trace tracesetting
trace var [varlist]</langsyntaxhighlight>
:where ''tracesetting'' is one of:
:*'''<tt>all</tt>'''
Line 401 ⟶ 542:
 
And here are some examples:
<langsyntaxhighlight Nimlang="nim">{.checks: off, optimization: speed.} # Checks are deactivated and code is generated for speed.
 
# Define a type Color as pure which implies that value names are declared in their own scope
Line 429 ⟶ 570:
...
{.pop.}
# From here, checks are deactivated again.</langsyntaxhighlight>
 
=={{header|Perl}}==
Line 452 ⟶ 593:
Pragmatic modules have local scope and are utilized using the use directive:
 
<langsyntaxhighlight lang="perl">use warnings; # use warnings pragma module
use strict; # use strict pragma module</langsyntaxhighlight>
 
To disable behaviour of a pragmatic module:
 
<langsyntaxhighlight lang="perl">no warnings; # disable warnings pragma module
no strict; # disable strict pragma module</langsyntaxhighlight>
 
=={{header|Phix}}==
The following are taken directly from the Phix.syn (syntax colouring) file, which can be edited as needed (for errors or new compiler features): <br>
Delimiters #$:.%\^ <br>
Operators , = := == != < <= > >= @= @== @!= @< @<= @> @>= + - * / += -= *= /= @+= @-= @*= @/= .. & &= ? ; : | ~ .<br>
Braces 7 ()[]{} <br>
BlockComment /* */ --/* --*/ #[ #] <br>
LineComment -- // <br>
TokenStart abcedfghijklmnopqrstuvwxyz <br>
TokenStart ABCDEFGHIJKLMNOPQRSTUVWXYZ_ <br>
Line 474 ⟶ 615:
The last line means that escapes in string literals start with a backslash, and there are 14 of them: CR, LF,
TAB, backslash, single and double quotes, escape (#1B, e and E allowed), hex byte (# and x allowed), NUL,
backspace, and 4 and 8-digit unicode characters. The 7 in Braces is just the number of nested colours to use.
 
(The above is further explained on [[[[Special_characters#Phix|Special_characters]]]])
Line 482 ⟶ 623:
 
The #ilASM{} directive contains inline assembly, which can contain PE/ELF/32/64 guards to control the exact
code emitted, (mainly for low-level system routines, such as file I/O, which are usually in builtins\VM). One
day I hope/expect to add a JS guard, for pwa/p2js, but there isn't one yet.
 
The #isginfo{}, #isinit{}, and #istype{} directives instruct the compiler to perform various type-inference
Line 489 ⟶ 631:
 
The with/without directives control several run-time options: <br>
javascript -- ensure pwa/p2js compatible, ie can be run in a browser, equivalent to js and javascript_semantics<br>
profile -- produce an execution count listing when the program terminates<br>
profile_time -- produce an execution percentage listing when the program terminates<br>
safe_mode -- see [[[[Untrusted_environment#Phix]]]]<br>
type_check -- turn user-defined type checking on or off (can make it noticeably faster, once testing is done)<br>
trace -- allow or disallow debugging (source code line-by-line tracing) <br>
debug -- turn debugging info generation on or off <br>
nested_globals -- fine-grained scope control, nested_locals is the complementary option <br>
 
The last two are related: without debug completely removes all tracing and diagnostics for a specific file (primarily intended for use in well-tested system routines), whereas (under with debug, which is the default) with/without trace can make debugging less tedious by not stopping on every line of irrelevant (user-selected) code, although dumps still contain a full call stack. Some other options, specifically indirect_includes, inline, and digital stamps, exist solely for compatability and are completely ignored.
 
with/without console/gui still work but should now be replaced with a format directive:
 
format PE32|PE64|ELF32|ELF64 - you can also specify gui/console, subsystem version, icons and manifest files. Ignored when interpreting/transpiling.
 
The following are ignored by the compiler, but are respected by the source code reindent tool: <br>
Line 507 ⟶ 652:
--#withtype <br>
 
Lastly noteNote that an abort() statement at the top level will make the compiler ignore the rest of the file.
 
While technically code rather than a directive, the requires() builtin can hopefully avoid fruitless efforts to run something where it is simply never going to work, eg
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #7060A8;">requires</span><span style="color: #0000FF;">(</span><span style="color: #004600;">JS</span><span style="color: #0000FF;">)</span>
<span style="color: #000080;font-style:italic;">--requires(WINDOWS) -- (one of only, or
--requires(LINUX) -- a special combo)</span>
<span style="color: #7060A8;">requires</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"1.0.2"</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">requires</span><span style="color: #0000FF;">(</span><span style="color: #000000;">32</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- or 64</span>
<!--</syntaxhighlight>-->
 
=={{header|PicoLisp}}==
Line 524 ⟶ 678:
an array.
For example:
<langsyntaxhighlight lang="pli"> declare (t(100),i) fixed binary;
i=101;
t(i)=0;</langsyntaxhighlight>
will cause unpredictible results.
And :
<langsyntaxhighlight lang="pli"> (SubscriptRange): begin;
declare (t(100),i) fixed binary;
i=101;
t(i)=0;
end;</langsyntaxhighlight>
will issue the message : "The SubscriptRange condition was raised." at execution time.
<br>Or, it can be handle by an on-unit.
<langsyntaxhighlight lang="pli"> (SubscriptRange): begin;
declare (t(100),i) fixed binary;
i=101;
Line 542 ⟶ 696:
t(i)=0;
e:on SubscriptRange system; /* default dehaviour */
end;</langsyntaxhighlight>
<br>And the same way for a string,
the '''StringRange''' condition is raised when a substring reference is beyond
Line 560 ⟶ 714:
You can use #Requires statements in any script. You cannot use them in
functions, cmdlets, or snap-ins.
<syntaxhighlight lang="powershell">
<lang PowerShell>
#Requires -Version <N>[.<n>]
#Requires –PSSnapin <PSSnapin-Name> [-Version <N>[.<n>]]
Line 566 ⟶ 720:
#Requires –ShellId <ShellId>
#Requires -RunAsAdministrator
</syntaxhighlight>
</lang>
For a full description:
<syntaxhighlight lang="powershell">
<lang PowerShell>
Get-Help about_Requires
</syntaxhighlight>
</lang>
 
=={{header|PureBasic}}==
PureBasic supports several pragmatic directives, also known as '''[https://www.purebasic.com/documentation/reference/compilerdirectives.html compiler directives]'''.
 
<code>CompilerIf…CompilerElseIf…CompilerElse…CompilerEndIf</code>: allows certain parts of the code to be compiled depending on the evaluation of a constant expression.
<syntaxhighlight lang="vb">CompilerIf #PB_Compiler_OS = #PB_OS_Linux
; some Linux specific code
CompilerElse
; some code for other operating systems
CompilerEndIf</syntaxhighlight>
 
<code>CompilerSelect…CompilerCase…CompilerDefault…CompilerEndSelect</code>: Allows you to select which code to compile based on a constant numeric value.
<syntaxhighlight lang="vb">CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_MacOS
; some Mac OS
CompilerCase #PB_OS_Linux
; some Linux specific code
CompilerEndSelect</syntaxhighlight>
 
<code>CompilerError</code> and <code>CompilerWarning</code>: generate an error or a warning, respectively.
<syntaxhighlight lang="vb">CompilerIf #PB_Compiler_OS = #PB_OS_Linux
CompilerError "Linux is not supported, sorry."
CompilerElse
CompilerWarning "OS supported, you can now comment me."
CompilerEndIf</syntaxhighlight>
 
<code>EnableExplicit</code> and <code>DisableExplicit1</code>: Enable or disable explicit mode. When enabled, all variables not explicitly declared with Define, Global, Protected, or Static will not be accepted and the compiler will generate an error.
<syntaxhighlight lang="vb">EnableExplicit
Defines
a = 20 ; Ok, as declared with 'Define'
b = 10 ; Will raise an error here</syntaxhighlight>
 
<code>EnableASM</code> and <code>DisableASM</code>: Enable or disable the inline assembler. When enabled, all assembler keywords are available directly in the source code.
<syntaxhighlight lang="vb">; x86 assembly example
Test = 10
EnableASM
MOV dword [v_Test],20
DisableASM
DebugTest ; Will be 20</syntaxhighlight>
 
It is important to note that the scope of these directives is global, that is, they affect all code after them until a directive is found that disables them or until the end of the code file.
 
=={{header|Python}}==
Line 576 ⟶ 771:
 
;Python 3.2:
<langsyntaxhighlight lang="python">Python 3.2 (r32:88445, Feb 20 2011, 21:30:00) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import __future__
>>> __future__.all_feature_names
['nested_scopes', 'generators', 'division', 'absolute_import', 'with_statement', 'print_function', 'unicode_literals', 'barry_as_FLUFL']
>>> </langsyntaxhighlight>
 
('barry_as_FLUFL' is an April fools [http://www.python.org/dev/peps/pep-0401/ joke])
 
;Python 2.7:
<langsyntaxhighlight lang="python">Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import __future__
>>> __future__.all_feature_names
['nested_scopes', 'generators', 'division', 'absolute_import', 'with_statement', 'print_function', 'unicode_literals']
>>> </langsyntaxhighlight>
 
=={{header|Racket}}==
Line 601 ⟶ 796:
{{works with|rakudo|2015-10-20}}
The Perl 6 pragma mechanism is nearly identical to Perl 5's, piggybacking on the notation for importing modules (pragmas are distinguished by case from normal modules, which are generally of mixed case). By convention pragmas are lowercase, unless they are indicating the use of an unsafe feature, in which case they are in all caps.
<syntaxhighlight lang="raku" perl6line>use MONKEY-TYPING;
augment class Int {
method times (&what) { what() xx self } # pretend like we're Ruby
}</langsyntaxhighlight>
Unlike Perl 5, there is no <tt>use strict;</tt> pragma, however, since Perl 6 is strict by default. Importation of a pragma is lexically scoped as in Perl 5, but note that unlike in Perl 5, <i>all</i> importation is lexical in Perl 6, so pragmas are not special that way.
 
Line 771 ⟶ 966:
 
For external routines, the defaults are used. <br><br>
 
=={{header|RPL}}==
Pragmatic directives are given through system flags that can bet with the <code>SF</code> and <code>CF</code> commands anywhere in a program.
System flags are a legacy of programmable calculators and unfortunately, which flag to set or reset for a specific directive depends on the calculator model you are using.
As an example, here are the directives controlled by flags on HP-28 models:
* LAST variable activated
* Immediate evaluation of constants (e, pi...) and functions
* length of binary words
* display and print formats
* decimal sign and object separator
* real number display format
* sound on/off
* underflow/overflow error handling
 
 
Fortunately, some of them can also be operated through language commands, such as <code>STWS</code> (defines the length of binary words) or <code>RAD</code> (defines radian as the trigonometric unit).
 
=={{header|Scala}}==
===tailrec===
<langsyntaxhighlight Scalalang="scala">@inline
@tailrec</langsyntaxhighlight>
 
=={{header|Tcl}}==
Line 802 ⟶ 1,013:
Pragmatic directives remain effective, until they are deactivated, or the end of the script is reached:
 
<langsyntaxhighlight lang="sh">set -vx # Activate both script line output and command line arguments pragma
set +vx # Deactivate both pragmatic directives</langsyntaxhighlight>
 
=={{header|Wren}}==
Line 810 ⟶ 1,021:
Import statements can appear anywhere a variable declaration is allowed and in particular within conditional structures. This enables us to do things such as the following:
 
<langsyntaxhighlight ecmascriptlang="wren">/* windows.wren */
 
class Windows {
static message { "Using Windows" }
static lineSeparator { "\\r\\n" }
}</langsyntaxhighlight>
 
<langsyntaxhighlight ecmascriptlang="wren">/* linux.wren */
 
class Linux {
static message { "Using Linux" }
static lineSeparator { "\\n" }
}</langsyntaxhighlight>
 
<syntaxhighlight lang="wren">/* Pragmatic_directives.wren */
<lang ecmascript>/*pragmatic_directives.wren*/
 
import "os" for Platform
Line 830 ⟶ 1,041:
var os
if (Platform.isWindows) {
import "./windows" for Windows
os = Windows
} else {
import "./linux" for Linux
os = Linux
}
System.print("%(os.message) which has a \"%(os.lineSeparator)\" line separator.")</langsyntaxhighlight>
 
{{out}}
From the last script, when run on a Linux system.
<pre>
$ wren_cli pragmatic_directivesPragmatic_directives.wren
Using Linux which has a "\n" line separator.
</pre>
7,794

edits