aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarshall Lochbaum <mwlochbaum@gmail.com>2021-04-15 08:29:19 -0400
committerMarshall Lochbaum <mwlochbaum@gmail.com>2021-04-15 08:29:19 -0400
commitc358718f7585bfe615a2590a090d98002ab2a44e (patch)
tree913042bcf6c95e6cf517fa41d0c42f19b6cb0cb0
parentdac0ef523cbd97e5c8df8678489ef0b9c57badfb (diff)
•Show and •Exit
-rw-r--r--docs/spec/system.html11
-rw-r--r--spec/system.md14
2 files changed, 19 insertions, 6 deletions
diff --git a/docs/spec/system.html b/docs/spec/system.html
index b2378648..eeb02814 100644
--- a/docs/spec/system.html
+++ b/docs/spec/system.html
@@ -62,6 +62,10 @@
<td><code><span class='Value'>•name</span></code></td>
<td>Current filename</td>
</tr>
+<tr>
+<td><code><span class='Function'>•Exit</span></code></td>
+<td>Leave the top-level running program</td>
+</tr>
</tbody>
</table>
<p><code><span class='Function'>•Import</span></code> loads another BQN script. The script is evaluated in its own isolated scope, and its result is either the result of the last line, or a module if it exports with <code><span class='Gets'>⇐</span></code> at the top level. If it is a module, then it must be destructured immediately unless first-class namespaces are possible.</p>
@@ -69,6 +73,7 @@
<p><code><span class='Value'>•args</span></code> is the arguments passed as the file was invoked, either from the command line or <code><span class='Function'>•Import</span></code>. For command line calls it is a list of strings.</p>
<p><code><span class='Value'>•path</span></code> simply gives the path of the file in which it appears. It includes a trailing slash but not the name of the file itself.</p>
<p><code><span class='Value'>•name</span></code> gives the name, including the extension, of the file in which it appears. It doesn't include the path.</p>
+<p><code><span class='Function'>•Exit</span></code> immediately terminates the running BQN process. If the argument is a valid return code (on Unix, an integer), it is returned; otherwise, the default return code (the one returned when the end of the program is reached) is used.</p>
<h2 id="files">Files</h2>
<p>The system namespace value <code><span class='Value'>•file</span></code> deals with file operations. For the purposes of <code><span class='Value'>•file</span></code>, paths in the filesystem are always strings. As with <code><span class='Function'>•Import</span></code>, file paths may be relative or absolute, and relative paths are relative to <code><span class='Value'>•path</span></code>, except in <code><span class='Value'>•file.</span><span class='Function'>At</span></code> which allows <code><span class='Value'>𝕨</span></code> to specify an alternate base directory. The value <code><span class='Value'>•path</span></code> used for a particular instance of <code><span class='Value'>•file</span></code> is determined by the file that contains that instance.</p>
<p>When a <code><span class='Value'>•file</span></code> function returns a file path or portion of a path, the path is always absolute and canonical, with <code><span class='Value'>.</span></code> and <code><span class='Value'>..</span></code> components removed.</p>
@@ -265,12 +270,16 @@
<td>Print argument string</td>
</tr>
<tr>
+<td><code><span class='Function'>•Show</span></code></td>
+<td>Print argument value</td>
+</tr>
+<tr>
<td><code><span class='Function'>•Fmt</span></code></td>
<td>Format value for printing</td>
</tr>
</tbody>
</table>
-<p><code><span class='Function'>•Out</span></code> prints to stdout, with a trailing newline. <code><span class='Function'>•Fmt</span></code> returns a string (not a character table: lines are separated by linefeeds) indicating how <code><span class='Value'>𝕩</span></code> would be printed by the interactive environment.</p>
+<p><code><span class='Function'>•Out</span></code> prints a string to stdout, with a trailing newline. <code><span class='Function'>•Show</span></code> displays a BQN value to the programmer (the representation is not specified, and does not need to be plain text). <code><span class='Function'>•Fmt</span></code> returns a string (not a character table: lines are separated by linefeeds) indicating how <code><span class='Value'>𝕩</span></code> would be printed by the interactive environment. Both <code><span class='Function'>•Show</span></code> and <code><span class='Function'>•Fmt</span></code> may take a left argument configuring how the value should be formatted.</p>
<h2 id="operation-properties">Operation properties</h2>
<table>
<thead>
diff --git a/spec/system.md b/spec/system.md
index 01664e5e..dd17f471 100644
--- a/spec/system.md
+++ b/spec/system.md
@@ -29,6 +29,7 @@ The effect of `•Eval` should be the same as if its argument were written as so
| `•args` | Arguments passed to current file
| `•path` | Current file's path
| `•name` | Current filename
+| `•Exit` | Leave the top-level running program
`•Import` loads another BQN script. The script is evaluated in its own isolated scope, and its result is either the result of the last line, or a module if it exports with `⇐` at the top level. If it is a module, then it must be destructured immediately unless first-class namespaces are possible.
@@ -40,6 +41,8 @@ The right argument is a filename, which may be relative or absolute. Relative pa
`•name` gives the name, including the extension, of the file in which it appears. It doesn't include the path.
+`•Exit` immediately terminates the running BQN process. If the argument is a valid return code (on Unix, an integer), it is returned; otherwise, the default return code (the one returned when the end of the program is reached) is used.
+
## Files
The system namespace value `•file` deals with file operations. For the purposes of `•file`, paths in the filesystem are always strings. As with `•Import`, file paths may be relative or absolute, and relative paths are relative to `•path`, except in `•file.At` which allows `𝕨` to specify an alternate base directory. The value `•path` used for a particular instance of `•file` is determined by the file that contains that instance.
@@ -126,12 +129,13 @@ The following short names can also be provided for file access. They can be prov
## Input and output
-| Name | Summary
-|--------|----------------------
-| `•Out` | Print argument string
-| `•Fmt` | Format value for printing
+| Name | Summary
+|---------|----------------------
+| `•Out` | Print argument string
+| `•Show` | Print argument value
+| `•Fmt` | Format value for printing
-`•Out` prints to stdout, with a trailing newline. `•Fmt` returns a string (not a character table: lines are separated by linefeeds) indicating how `𝕩` would be printed by the interactive environment.
+`•Out` prints a string to stdout, with a trailing newline. `•Show` displays a BQN value to the programmer (the representation is not specified, and does not need to be plain text). `•Fmt` returns a string (not a character table: lines are separated by linefeeds) indicating how `𝕩` would be printed by the interactive environment. Both `•Show` and `•Fmt` may take a left argument configuring how the value should be formatted.
## Operation properties