| | @@ -58,7 +58,9 @@ |
| 58 | 58 | array or a slice set to one value (section 6.8); a qualified case in a |
| 59 | 59 | `match` arm (section 7.4); a slice part written as a literal, and an |
| 60 | 60 | `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. |
| 62 | 64 | |
| 63 | 65 | The language is frozen, softly, from this version on: it changes only |
| 64 | 66 | to mend a defect, and its library grows only by what breaks no program |
| | @@ -381,7 +383,9 @@ |
| 381 | 383 | |
| 382 | 384 | A name must be declared before it is used, with two exceptions: the |
| 383 | 385 | 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 |
| 385 | 389 | procedure may be declared `forward` and defined later (section 8). |
| 386 | 390 | |
| 387 | 391 | **Constants** are evaluated by the compiler. Their expressions use only |
| | @@ -670,6 +674,18 @@ |
| 670 | 674 | their parameters have the same types, each `var`, `const` or neither |
| 671 | 675 | alike, in order, and their results are the same types; the parameters' |
| 672 | 676 | 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. |
| 673 | 689 | |
| 674 | 690 | ### 5.10 Same and assignable |
| 675 | 691 | |