Pragmatic directives: Difference between revisions

m
(add RPL)
m (→‎{{header|Wren}}: Minor tidy)
Line 956:
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:
 
<syntaxhighlight lang="ecmascriptwren">/* windows.wren */
 
class Windows {
Line 963:
}</syntaxhighlight>
 
<syntaxhighlight lang="ecmascriptwren">/* linux.wren */
 
class Linux {
Line 970:
}</syntaxhighlight>
 
<syntaxhighlight lang="ecmascriptwren">/*pragmatic_directives Pragmatic_directives.wren */
 
import "os" for Platform
Line 976:
var os
if (Platform.isWindows) {
import "./windows" for Windows
os = Windows
} else {
import "./linux" for Linux
os = Linux
}
Line 987:
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>
9,476

edits