From 0c519645710b966e05ef2928781704a71ca62e0e Mon Sep 17 00:00:00 2001 From: Luis <42945842+ldiaz94@users.noreply.github.com> Date: Fri, 23 Oct 2026 13:19:35 +0100 Subject: [PATCH] raz.md: a record's procedure field may take the record --- diff --git a/doc/raz.md b/doc/raz.md index b589aca..9590536 100644 --- a/doc/raz.md +++ b/doc/raz.md @@ -58,7 +58,9 @@ array or a slice set to one value (section 6.8); a qualified case in a `match` arm (section 7.4); a slice part written as a literal, and an `ERROR` constant named by another (sections 4 and 5.8); and a `const` -parameter's slice returned (section 7.3); it breaks no program. +parameter's slice returned (section 7.3); and a procedure type's +parameter or result may name a type declared later in its `type` +section (sections 4 and 5.9); it breaks no program. The language is frozen, softly, from this version on: it changes only to mend a defect, and its library grows only by what breaks no program @@ -381,7 +383,9 @@ A name must be declared before it is used, with two exceptions: the base type of a pointer may name a type declared later in the same -`type` section (so that two records can point at each other), and a +`type` section (so that two records can point at each other), and so +may a parameter or a result of a procedure type there, however passed +(so that a record's callback can take the record, section 5.9); and a procedure may be declared `forward` and defined later (section 8). **Constants** are evaluated by the compiler. Their expressions use only @@ -670,6 +674,18 @@ their parameters have the same types, each `var`, `const` or neither alike, in order, and their results are the same types; the parameters' names don't matter. + +A parameter or a result of a procedure type in a `type` section may +name a type declared later in it, a record that is being declared too: + +``` +type Lines = record each: proc(var r: Lines; s: []U8); n: INT; end; +``` + +A procedure value is an address whatever its signature, so the record's +size doesn't depend on it; the type is whole when a call is made. A +field of the record's own type, by value, is still an error, since +nothing would be big enough. ### 5.10 Same and assignable diff --git a/doc/report-history.md b/doc/report-history.md index c302204..691bd2e 100644 --- a/doc/report-history.md +++ b/doc/report-history.md @@ -252,5 +252,8 @@ elsewhere, `| Xml.done:` (section 7.4). A constant's slice part may be an array literal, `[[1, 2], [3]]`, and an `ERROR` constant may be another `ERROR` constant, the same error (sections 4 and 5.8). A - slice of a `const` parameter may be returned (section 7.3). Appendix - A says what a wipe can't reach. It breaks no program. + slice of a `const` parameter may be returned (section 7.3). A + parameter or a result of a procedure type may name a type declared + later in the same `type` section, so that a record's callback can + take the record (sections 4 and 5.9). Appendix A says what a wipe + can't reach. It breaks no program.