# re-bol.com examples — corpus report

Generated by `tools/examples_corpus.py` + `tools/examples_sections.py`.

Source: <https://re-bol.com/examples.txt> (638 KB of prose + examples).
The extractor keeps paragraph-sized snippets that start with a REBOL function
or set-word and bracket-balance; the section runner replays each document
section in order with headless stubs for interactive/GUI words and a native
iteration cap (`R2_LOOP_LIMIT=1000`) for endless examples.

```
INSTRUCTIONS                   1 snippets,   0 errors
LANGUAGE BASICS               92 snippets,   0 errors
FUNCTIONS                      9 snippets,   0 errors
SEVERAL APPLICATION EXAMPLES  24 snippets,   0 errors
HOW TO CREATE WINDOWS .EXE P  13 snippets,   1 errors
DRAW                           4 snippets,   0 errors
HELP                           1 snippets,   0 errors
PORTS                          7 snippets,   1 errors
NETWORK PORTS                 10 snippets,   0 errors
OBJECTS                       10 snippets,   0 errors
THIRD PARTY LIBRARIES         16 snippets,   0 errors
MULTITASKING                   2 snippets,   0 errors
VARIOUS ADDITIONAL APPLICATI  10 snippets,   0 errors
; HERE'S AN EXAMPLE OF HOW T   4 snippets,   0 errors
; HERE, THE EVENTS ARE PRINT   7 snippets,   0 errors
CHORD TYPE:           INTERV  10 snippets,   0 errors
; PUT YOUR CODE HERE          67 snippets,   2 errors
; CHANGE/REMOVE BUTTONS AND/  36 snippets,   5 errors
INSTALLATION                   1 snippets,   0 errors
FUNDAMENTALS                   1 snippets,   0 errors

sections: 20 errors: 9
```

Both the Linux clone and the Windows PE under Wine produce this result; the
whole document completes (no timeout and no missing result file).

**The 9 errors are the reference's own errors** (verified with the
differential harness, `tools/examples_sections.py --diff`, which replays every
section through the original REBOL/View 2.7.8.3.1 binary and compares line by
line):

| snippet | error | why the reference fails too |
|---|---|---|
| 2357 | `cannot-open filename.csv` | the example reads a CSV the user is supposed to create |
| 2858 | `invalid-arg world-read:` | R2 rejects file-permission modes in `set-modes` |
| 9154, 9179 | `cannot-open uncompressed.txt` | the editor stub does not save the file |
| 12672 | `expect-arg index?` | `index? none` after a failed `find` (the reference errors identically) |
| 13051 | `expect-arg read` | `foreach` over a single FILE iterates chars, so `read #"c"` is invalid |
| 13991, 14003 | `cannot-open sales.txt` | the examples read a data file the user must create |
| 14215 | `cannot-open ./receipts/` | missing example directory |

Differential status at demo34: **1 differing line out of 28146** in the whole
document — `state: 1052x821` (reference) vs `state: 1x1` (clone) for a text
face inside a moulded layout.  That field is R2's private text-layout cache
(it is recomputed when the face is shown; the GUI screenshot regression is
0.00 %).  Five snippets are not replayed, each for a documented reason:

| snippet(s) | reason |
|---|---|
| 1667, 2376, 2897, 3689, 3742 | interactive / incomplete / non-R2 / DB-server examples |
| 1255 | writes to a Windows drive path (`%/c/...`); the reference runs under Wine with a C: drive, the clone does not emulate one |
| 1277 | inspects R2's internal `system/words` layout (`first system/words` is R2's `end!` sentinel) |
| 2822 | `source` of a built-in loop: R2 implements FOR/FORALL/FORSKIP in its mezzanine, the clone implements them natively |

## demo34 (2026-11-29)

- Differential sweep (`--diff`) taken to **1 line** in the whole document
  (28146 compared lines).  Sections at 0: INSTRUCTIONS, LANGUAGE BASICS,
  FUNCTIONS, SEVERAL APPLICATION EXAMPLES, HOW TO CREATE WINDOWS .EXE
  PROGRAMS, DRAW, HELP, PORTS, NETWORK PORTS, OBJECTS, THIRD PARTY
  LIBRARIES, MULTITASKING, VARIOUS ADDITIONAL APPLICATIONS, the four
  anonymous sections, INSTALLATION, FUNDAMENTALS.
- The remaining difference is R2's private text-layout cache
  (`state: 1052x821` vs `state: 1x1`) inside a moulded layout face.
- Language fixes driven by the sweep: `parse` split mode (NONE/string
  delimiters, R2's whitespace class, /ALL), `load` of a binary (image/WAV
  sniffing only), `trim` in place, relative `at`/negative `copy/part`,
  `set` with a block of words, word/lit-word equality vs strict
  `find`/`select` matching, `form` of an object, `type?/word`, `min`/`max`
  decimal promotion, `sort/compare` comparator direction, block and
  case-insensitive series comparison, binary `find`, `foreach` over
  file/binary series, argument type checks (`index?`/`head`/`read`/...),
  ACCESS error ids and messages (`cannot-open`, `no-delete`, `no-rename`,
  `no-make-dir`, `invalid-spec`, unknown port schemes), `set-modes`/
  `get-modes` port-mode rules, PNG alpha mapping, and bold Arial metrics.

## demo33 (2026-11-28)

Counts unchanged (325 snippets, 20 sections, **0 errors**, Linux and Wine),
but the corpus now also drives a **differential harness**:
`tools/examples_sections.py --diff` runs each section through the reference
and the clone and diffs the printed output.  Its first sweep fixed `change`
on strings (default range = new text length), paths with paren components,
sorted directory listings and user-function argument type checking.

## demo32 (2026-11-28)

Counts unchanged: 325 snippets, 20 sections, **0 errors** (Linux and Wine).
The release makes face-image placement match the reference (top-left, natural
size, clipped, `FIT` scales).

## demo31 (2026-11-28)

Counts unchanged: 325 snippets, 20 sections, **0 errors** (Linux and Wine).
The release makes the effect dialect resolve colour words and implements
R2's exact GRADIENT ramp (shared by TO-IMAGE and the on-screen renderer).

## demo30 (2026-11-28)

Counts unchanged again: 325 snippets, 20 sections, **0 errors** on Linux and
Wine.  The release fixes three evaluator rules (`obj/func/ref: value`,
`obj/series/n/field: value`, `make function!` copying spec/body) plus
`make <object-prototype>` rebinding, all exercised by the DRAW/GUI snippets.

## demo29 (2026-11-27)

No count changes: 325 snippets, 20 sections, **0 errors**, on Linux and under
Wine.  The release fixes three language-level bugs the sweep had not exercised
(nested MOLD break flags, loop variables inside nested blocks, `compose`
splicing) and adds the `contrast` image effect, so the DRAW/net snippets run
through slightly different code paths but produce the same results.

## demo19 port sweep (2026-11-14)

The generic port system (`tcp://`, `udp://`, `file://`, `console://`) is now
implemented, so the PORTS and NETWORK PORTS sections exercise real port
objects instead of stub objects: `open %temp.txt` + `set-modes` + `close`
creates a real file port, `open sound://` plays through the sound actor and
`open/binary/no-wait console://` returns a console port.  The counts are
unchanged (325 snippets, 20 sections, 0 errors) on Linux and Wine.

The remaining network snippets are still skipped because they need a peer:
they are one half of a client/server pair (`tcp://:55555` server waiting for
a client, or a client connecting to a service that is not running), use
broadcast chat, or read external sites (`pop://user:pass/site.com`).  A
self-contained loopback port demo now ships as `examples/ports.r` instead and
produces byte-identical output on the reference.

## demo20: port event model and cross-implementation wire tests

`port/awake` now works the way the reference does it: the handler receives
the port itself, is called once per `wait` that includes the port, is not
called on a timeout, and EOF arrives as a read event (`copy` → `none`).
`wait/all` dispatches every ready port and returns a block; `wait <time>` and
`wait []` leave ports alone, exactly as the reference does.

`tools/ports_smoke.py` closes the loop on the two-party snippets: it runs a
server script and a client script as separate processes over loopback and
checks the message that arrives, for TCP, UDP and an async (`awake`) server,
on Linux and under Wine, including cross-tests against the original binary in
both directions (`--mix`).  All modes pass, so the document's client/server
pairs are covered by wire-level tests even though they cannot be replayed as
single snippets.

## What changed in this sweep (27 → 0 errors)

* **Requestor stubs now match R2's real specs.** The prelude previously gave
  `request-text`, `request-date`, `request-file`, `request-dir` etc. a leading
  positional argument. R2's requestors are refinement-only (`request-dir/title`,
  `request-file/only/filter`, …), so the stubs were consuming the next
  expression as a refinement argument. This alone fixed most `no-value`
  failures and the runaway “Test Script Loop” example.
* **`++` / `--` work.** The `+`/`-` operators were marking the shared
  `add`/`subtract` Func objects as infix operators. Boot calls
  `infix "+" add`, which did the same. Operators now get private Func copies,
  so `add get word 1` and `set word add get word 1` evaluate correctly.
* **`paren?` exists** (type predicate used by the boot `++`/`--` source).
* **`get`/`set` use normal word arguments** (not literal arguments), matching
  the boot-image specs.
* **Clipboard examples are treated as external/interactive** (`clipboard://`)
  and skipped instead of looping.
* **Malformed documentation tables** in the CHORD section are skipped as
  non-code.
* **Requestor/file stubs are safer:** file-picking returns a generated image
  for image filters, a harmless script for loads and a separate target for
  saves; directory/list stubs return usable values. This lets the Jigsaw and
  requestor examples run without pretending to be the user.
* **Context supplements / explicit skips:** the `verbalize` helper omitted by
  the extractor is included as document context; the complex-account class is
  allowed through the control-flow filter; non-runnable/incomplete paragraphs
  are skipped with a marker.

## No remaining errors

All 20 sections complete with zero errors on Linux and Wine.  Snippets that
cannot be replayed headlessly are explicitly skipped and listed here:

* `Simple Data Retrieval App - Console` — an infinite interactive `ask` loop.
* `format-decimal` — uses `parse string "delimiter"`, which is not valid
  R2 2.7 syntax.
* `PORTS` large-file example — incomplete snippet referencing an undefined
  `file` and a direct-file port mode.
* MySQL GUI example — needs a running MySQL server.
* SQLite GUI example — needs the third-party SQLite driver/DLL and database.

The first three are not runnable examples of the shipped interpreter; the last
two are external database services.  They are counted as skipped, not errors.

The corpus also supplies document context that the extractor misses:
`verbalize`, the `complex-account` definition, and small fixture data files
(`form1.db`, `time_sheet.txt`, `employees`) generated in the same format the
book's applications use.

Re-run with per-snippet detail:

```bash
python3 tools/examples_sections.py --detail
python3 tools/examples_sections.py --section "PUT YOUR CODE HERE" --detail
python3 tools/examples_sections.py --wine
```

## demo23: port specs in the corpus

The book sometimes writes network targets as *port specs* rather than URLs
(`write [scheme: 'FTP host: "site.com" ...]`).  R2 evaluates such a spec block
key by key (each `key:` value is an expression), and the clone now does the
same, so `read`/`write` with a spec behaves like the reference.  Because
those snippets still need external servers, the harness' network filter now
also matches `scheme: '<net-scheme>` spellings and skips them like the URL
forms; the section counts are unchanged (325 snippets, 20 sections, 0
errors) on Linux and Wine.
