raz / commit 0c519645

commit
0c519645710b966e05ef2928781704a71ca62e0e
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
74519995
raz.md: a record's procedure field may take the record

patch · log

2 files changed, +23 -4

doc/raz.md (history) modified +18 -2

@@ -58,7 +58,9 @@
5858 array or a slice set to one value (section 6.8); a qualified case in a
5959 `match` arm (section 7.4); a slice part written as a literal, and an
6060 `ERROR` constant named by another (sections 4 and 5.8); and a `const`
61-parameter's slice returned (section 7.3); it breaks no program.
61+parameter's slice returned (section 7.3); and a procedure type's
62+parameter or result may name a type declared later in its `type`
63+section (sections 4 and 5.9); it breaks no program.
6264
6365 The language is frozen, softly, from this version on: it changes only
6466 to mend a defect, and its library grows only by what breaks no program
@@ -381,7 +383,9 @@
381383
382384 A name must be declared before it is used, with two exceptions: the
383385 base type of a pointer may name a type declared later in the same
384-`type` section (so that two records can point at each other), and a
386+`type` section (so that two records can point at each other), and so
387+may a parameter or a result of a procedure type there, however passed
388+(so that a record's callback can take the record, section 5.9); and a
385389 procedure may be declared `forward` and defined later (section 8).
386390
387391 **Constants** are evaluated by the compiler. Their expressions use only
@@ -670,6 +674,18 @@
670674 their parameters have the same types, each `var`, `const` or neither
671675 alike, in order, and their results are the same types; the parameters'
672676 names don't matter.
677+
678+A parameter or a result of a procedure type in a `type` section may
679+name a type declared later in it, a record that is being declared too:
680+
681+```
682+type Lines = record each: proc(var r: Lines; s: []U8); n: INT; end;
683+```
684+
685+A procedure value is an address whatever its signature, so the record's
686+size doesn't depend on it; the type is whole when a call is made. A
687+field of the record's own type, by value, is still an error, since
688+nothing would be big enough.
673689
674690 ### 5.10 Same and assignable
675691

doc/report-history.md (history) modified +5 -2

@@ -252,5 +252,8 @@
252252 elsewhere, `| Xml.done:` (section 7.4). A constant's slice part may
253253 be an array literal, `[[1, 2], [3]]`, and an `ERROR` constant may be
254254 another `ERROR` constant, the same error (sections 4 and 5.8). A
255- slice of a `const` parameter may be returned (section 7.3). Appendix
256- A says what a wipe can't reach. It breaks no program.
255+ slice of a `const` parameter may be returned (section 7.3). A
256+ parameter or a result of a procedure type may name a type declared
257+ later in the same `type` section, so that a record's callback can
258+ take the record (sections 4 and 5.9). Appendix A says what a wipe
259+ can't reach. It breaks no program.