Skip to content

Commit 910e1bb

Browse files
committed
Update docs
1 parent 5622d1b commit 910e1bb

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

docs/6MAT.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ Instruction arguments are denoted in this document and the instruction grammar u
4343
- `!V`: A character literal, `$V`, or `?V`
4444
- `$V`: A character literal, or `$V`
4545
- `'C`: A character literal
46-
- `!n`: A string literal, or `$n`, or `?n`
46+
- `!n`: A string literal, `$n`, or `?n`
4747
- `$n`: A string literal, or `$n`
4848
- `"X`: A string literal
4949
- `_I`: Any previously listed type (with potential restrictions)
5050

5151
Default values for arguments are denoted like `_I = default`. Passing `NIL` as an argument is equivalent to passing the default value. If an instruction has adjacent defaulted arguments of the same type, they are bound from left to right; e.g. if `FOO %N = 1, %M = 2` is called with `FOO 3`, then `3` is bound to `%N`.
5252

53-
Multiple `!n` arguments are never permitted in a single instruction call. If an instruction accepts `!n` and `"X` in a call, `n` must be the length of the string literal.
53+
Multiple `!n` arguments are never permitted in a single instruction call. If an instruction accepts `!n` and `"X` in a call, `n` must be the length of the string literal. Passing `!n` when fewer than `n` characters remain on the tape will result in a crash.
5454

5555
## Control Flow
5656

@@ -156,6 +156,8 @@ As such, the following calls are disallowed.
156156
- `IFLE! $V, !V { ... }`
157157
- `IFLT! $V, !V { ... }`
158158

159+
Furthermore, peeking in the second argument is somewhat inefficient in the general case to account for the tape pointer being near the end of the tape. Prefer using `$V` and backing up manually based on prior knowledge of the tape pointer.
160+
159161
#### `LOOP { ... }`
160162
Repeatedly execute the block, terminating if the tape is exhausted at the top of the block. Note that the tape pointer does *not* move by default at any point, and thus failing to cause net movement of the tape pointer during execution will result in a crash.
161163

@@ -293,7 +295,7 @@ As such, the following calls are disallowed.
293295

294296
## Printing
295297

296-
**Printing** a character results in its appearance in the next contents of the tape; it is only **output** to STDOUT at the end of the current lifetime if it appears after the last `\f` character. Printed characters cannot be overwritten or undone within a lifetime.
298+
**Printing** a character results in its appearance in the next contents of the tape; it is only **output** to STDOUT at the end of the current lifetime if it appears after the last `\f` character. Printed characters *cannot* be overwritten or undone within a lifetime.
297299

298300
#### `PRINA _I`
299301
Print `_I` as it appears, which may be a character or string variable.
@@ -331,7 +333,7 @@ Print `_K` using `PRINz _K` if the tape pointer is at the end of the tape (i.e.
331333
**Copying** instructions print some span of the tape without modification.
332334

333335
#### `COPY +N = 1`
334-
Copy exactly `N` characters. Equivalent to (but more readable than) [`PRINA $N`](#prina-_i).
336+
Copy exactly `N` characters (or until the tape is exhausted). More efficient than [`PRINA +N`](#prina-_i) in the case that at least `N` characters remain on the tape (i.e. `$R >= N`), and will not crash.
335337

336338
#### `COPYC! 'C, +N = 1`
337339
Copy characters up to but not including the `N`th succeeding appearance of `C`.
@@ -392,7 +394,7 @@ The value of `z` dictates padding options at the edges of the field.
392394
| `JUSTC` | Padding may be added at either edge of the field |
393395

394396
```
395-
JUST %N, %M, %L, !V {
397+
JUSTz %N, %M, %L, !V {
396398
[{ ... }]
397399
[{ ... }]
398400
...
@@ -407,7 +409,7 @@ Create a buffer by executing the block. If the output of the containing [`JUST`]
407409
Since this clause is always executed, breaking out of it cancels the entirety of the containing `JUST` instruction. Tape pointer movement is not undone.
408410

409411
```
410-
JUST %N, %M, %L, !V {
412+
JUSTz %N, %M, %L, !V {
411413
OVER %P, %O [{ ... }]
412414
[{ ... }]
413415
[{ ... }]

docs/samples/6MAT/sort.6mat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ DO {
1414
BRNR 2
1515
IFGT! $V, $V {
1616
BACK
17-
COPY
18-
BACK 2
17+
PRINA ?1
18+
BACK
1919
COPY
2020

2121
SKIP

0 commit comments

Comments
 (0)