| | @@ -7,8 +7,12 @@ |
| 7 | 7 | ## IMMINENT - APPROVED: what a call does with its arguments, written at the call |
| 8 | 8 | |
| 9 | 9 | **Status.** Approved by the owner, 2026-10-16, for the next thaw, and |
| 10 | | -revised on 2026-10-17 after a review of how it reads in real code. It |
| 11 | | -is five parts, made in one thaw so that programs break once: |
| 10 | +revised on 2026-10-17 after a review of how it reads in real code. A |
| 11 | +second review, the same day, found the questions listed at the end of |
| 12 | +part 1, "Open questions"; the owner judged the feature, and its use, |
| 13 | +not yet settled, and left them open. Only part 2 goes ahead, on its |
| 14 | +own and without the marks (2026-10-17). It is five parts, made in one |
| 15 | +thaw so that programs break once: |
| 12 | 16 | |
| 13 | 17 | 1. **Marks at the call** (this section): an argument for a `var` |
| 14 | 18 | parameter is written `var x`, and one for a `keep` parameter |
| | @@ -472,6 +476,65 @@ |
| 472 | 476 | |
| 473 | 477 | The examples of parts 2 and 3 are written as the whole thaw makes |
| 474 | 478 | them, with the marks of part 1. |
| 479 | + |
| 480 | +### Open questions |
| 481 | + |
| 482 | +The second review, 2026-10-17, read the five parts against `src/`, |
| 483 | +`lib/Opt.raz`, `tools/Pretty.raz` and `examples/Words.raz`. It found |
| 484 | +the direction sound, and parts 1, 2 and 4 clearly better in `tools/` |
| 485 | +and `Opt`, but mostly noise in `src/Parse.raz`, where `var x` stands |
| 486 | +on nearly every call. Left open, by the owner's word: |
| 487 | + |
| 488 | +1. **The seed.** A release of today's compiler can't read the marks |
| 489 | + either, so "the seed first" can't work as written: it takes two |
| 490 | + releases, one that accepts every new form without requiring it, |
| 491 | + made the seed, then one that marks `src/` and requires the marks. |
| 492 | +2. **Errors here.** `Opt.at` and `operand` move the `Parser` (`at` |
| 493 | + runs `next` to the end), so they are `var`, not `const`; the table |
| 494 | + row and part 1's `Opt.at(p)` are wrong. `Sys.entryKind` reads a |
| 495 | + `Dir` of 8 KB on Linux: `const` or `var`, not a value. Part 3's |
| 496 | + `Names.put(var table, keep buf[0..n], 1)` lacks `keep 1`. Part 5's |
| 497 | + table has a row part 1's lacks. Report 4 must let a variant's case |
| 498 | + stand in a constant expression. |
| 499 | +3. **A hole in part 3's exception for `var`.** `proc fill(var r: R); |
| 500 | + begin r.s := r.buf[0..4]; end;` passes, since `r` points where it |
| 501 | + pointed; a caller's local `r` copied to a module variable then |
| 502 | + points into a dead frame. Mend: the caller's variable and what its |
| 503 | + slices point at as two places, the exception covering the second. |
| 504 | +4. **Part 3's cost.** A local points wherever anything assigned to it |
| 505 | + does, which needs a closure over local-to-local assignments at |
| 506 | + `end` (`w, rest := Str.field(rest)`), and bits for locals, value |
| 507 | + parameters and `match`'s names: 400 to 600 lines, not 250 to 400. |
| 508 | +5. **Rule 6.** Its list contradicts itself: `keep - 1` and `keep[i]` |
| 509 | + are expressions today, and `Sys.closeAllBut(keep: []INT)` indexes |
| 510 | + `keep[i]`; `keep ^U8(p)` can't be marked. Proposed: decide by the |
| 511 | + heading, which is known when the argument is read: at a `keep` |
| 512 | + parameter a leading `keep` is the mark; elsewhere a name. |
| 513 | +6. **`keep` before what can't end is noise**: `keep 5`, `keep "Sh"`, |
| 514 | + and `keep k + 1`, which reads as `(keep k) + 1`. Proposed: optional |
| 515 | + before a constant or a basic or pointer type, required where the |
| 516 | + type carries a slice or is another module's record. It partly undoes |
| 517 | + rule 2's "the heading alone": one rule and some noise, or less noise |
| 518 | + and an exception. |
| 519 | +7. **A mark that lends nothing in a plain heading**, `keep n: INT`, |
| 520 | + costs every call a word. Proposed: a warning, but on a module |
| 521 | + parameter's type or a procedure with a body for each target. |
| 522 | +8. **`const`'s rules.** Check 4 must cover `match`'s names and views; |
| 523 | + whether a slice's elements count as "a part of it" (they shouldn't); |
| 524 | + a constant argument passed in place, not copied; `ret const` given a |
| 525 | + temporary that holds an array, an error. The heading's grammar, |
| 526 | + `Params = ["ret"] ["keep"] ["var" | "const"] ident ...`, and the |
| 527 | + call's, a designator after `var`. |
| 528 | +9. **Procedure types** with fewer marks are assignable, not the same: |
| 529 | + 5.10 must say so, for `=`, generic instances and `forward`. |
| 530 | + `Map`'s `eq` can't take a `const` equality. |
| 531 | +10. **Constants holding variants.** `match`'s names on one are read |
| 532 | + only; a pointer field takes only `nil`; an untyped `const D = dot`; |
| 533 | + padding zero; 30 to 40 lines, not 20. |
| 534 | +11. **False alarms to document.** A local container over a local |
| 535 | + buffer, `Scan.init(var s, keep line[0..n])`, is refused though both |
| 536 | + end together (a module variable, a `Buf` or the heap is the way |
| 537 | + out); so is a store through `ADR` of a local. |
| 475 | 538 | |
| 476 | 539 | ### Part 2: the library's parameters by `var`, not by pointer |
| 477 | 540 | |