Pragmatic directives: Difference between revisions
m
→{{header|Wren}}: Minor tidy
(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="
class Windows {
Line 963:
}</syntaxhighlight>
<syntaxhighlight lang="
class Linux {
Line 970:
}</syntaxhighlight>
<syntaxhighlight lang="
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
Using Linux which has a "\n" line separator.
</pre>
|