raz / commit 547d307f

commit
547d307fc7d650d1cf3407cbd7e1a419c1c1c0dc
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
fdb79e4b
PROPOSALS: continue accepted, the step before it

Its example puts the loop's step first, and says what a step after a
continue does; what it costs. concha's Csyntax among those met.

patch · log

1 file changed, +31 -5

PROPOSALS.md modified +31 -5

@@ -412,12 +412,38 @@
412412 ```
413413
414414 The proposal: `continue`, in a `while`, `repeat` or `for`, ends the
415-round, as reaching the end of the body would: a `for` steps its
416-variable, `repeat` tests its condition. A deferred statement can't
417-hold it, as it can't hold `break`. It breaks a program that has a name
418-`continue`, so it waits for a thaw.
415+round, as reaching the end of the body would: a `while` tests its
416+condition again, a `repeat` tests its `until`, a `for` steps its
417+variable. A deferred statement can't hold it, as it can't hold
418+`break`. With it, the loop above reads:
419419
420-Met in libro and rml, more than once each.
420+```
421+while i < LEN(t) do
422+ ch, n := Str.decode(t[i..LEN(t)]);
423+ i := i + n; (* the step first *)
424+ if ch = 0ADH then continue; end; (* passed over *)
425+ ...
426+end;
427+```
428+
429+The step comes before any `continue`. Put after it, as `i := i + n`
430+stood in the first loop, it is skipped, `i` never moves, and the loop
431+never ends; a `repeat`'s `until` may likewise read what the skipped
432+rest of the body was to set. A `for` steps itself and has neither
433+trap. The report's example shows the step first, and the compiler
434+can't catch it.
435+
436+It costs about 15 lines of the compiler (a second chain of jumps
437+beside `break`'s, fixed at each loop's test or step), a few lines of
438+the report (7.2, the reserved words, the grammar, 7.7), and a word in
439+`tools/Scan.raz` and the editors' modes. It breaks a program that has
440+a name `continue`; none of the raz programs written so far has one.
441+
442+Accepted by the owner, for a thaw.
443+
444+Met in libro and rml, more than once each, and in concha's
445+`Csyntax`, whose `interpolate` reads `elsif (c # '$') or not try
446+dollar(...)` for want of it.
421447
422448 ## A byte into an `INT`
423449