Report 2026-10.33: a const parameter, a variant in a constant, the library by var The ninth thaw, by the owner's word. A const parameter is the caller's variable read in place, never changed by the procedure, and takes any expression of its type (sections 5.9, 7.4, 8, 10). A typed constant may be a variant, or hold variants (section 4). The library's procedures that took a pointer to what they work on take var, const or a value instead; the library volume changes with each module, and the compiler follows 2026-10.32 until it has. STANDARDS.md says how a parameter is chosen; PROPOSALS.md keeps only the call-site marks, ret and keep.
| @@ -10,21 +10,24 @@ | ||
| 10 | 10 | 2026-10-17 (the second review's findings are under "Open questions", |
| 11 | 11 | at the end of part 1). The owner judged the feature, and its use, not |
| 12 | 12 | settled: no change is made for the marks at the call, `ret` or `keep`. |
| 13 | -Part 2, the library by `var`, is done on its own, without the marks. | |
| 13 | +Parts 2, 4 and 5, the library by `var`, a `const` parameter and a | |
| 14 | +variant in a constant, went into report 2026-10.33 on their own, | |
| 15 | +without the marks, and are no longer here. | |
| 14 | 16 | As drafted, it is five parts, to be made in one thaw so that programs |
| 15 | 17 | break once: |
| 16 | 18 | |
| 17 | 19 | 1. **Marks at the call** (this section): an argument for a `var` |
| 18 | 20 | parameter is written `var x`, and one for a `keep` parameter |
| 19 | 21 | `keep x`. |
| 20 | -2. **The library's parameters by `var`, not by pointer** (below): the | |
| 22 | +2. **The library's parameters by `var`, not by pointer** (now in the | |
| 23 | + report, 2026-10.33): the | |
| 21 | 24 | `ADR` that stands at nearly every call to the library goes. |
| 22 | 25 | 3. **`ret` and `keep`** (below): a heading says what a procedure does |
| 23 | 26 | with what it is given, and the compiler holds the body to it. |
| 24 | -4. **A `const` parameter** (below): a record or array only read is | |
| 27 | +4. **A `const` parameter** (now in the report): a record or array only read is | |
| 25 | 28 | passed in place, unmarked, so that `var` at a call always means a |
| 26 | 29 | change. |
| 27 | -5. **A constant holds a variant** (below): so that a table a procedure | |
| 30 | +5. **A constant holds a variant** (now in the report): so that a table a procedure | |
| 28 | 31 | keeps, as `Opt.init`'s, can be a constant, not a literal in the |
| 29 | 32 | frame. |
| 30 | 33 | |
| @@ -535,53 +538,7 @@ | ||
| 535 | 538 | buffer, `Scan.init(var s, keep line[0..n])`, is refused though both |
| 536 | 539 | end together (a module variable, a `Buf` or the heap is the way |
| 537 | 540 | out); so is a store through `ADR` of a local. |
| 538 | - | |
| 539 | -### Part 2: the library's parameters by `var`, not by pointer | |
| 540 | 541 | |
| 541 | -Most of the library's procedures take what they work on as `^T`: | |
| 542 | -`Buf.str(ADR(b), s)`, `Vec.push(ADR(v), x)`, `Lock.take(ADR(l))`. None | |
| 543 | -keeps it past the call; each reads or changes it and returns. That is | |
| 544 | -what `var` is for (8), and with it the call is `Buf.str(var b, s)`. As it | |
| 545 | -is, `ADR` stands at nearly every call a program makes to the library, | |
| 546 | -and says nothing: a reader can't tell the few places where a pointer | |
| 547 | -is kept from the many where it isn't. `STANDARDS.md` says how our own | |
| 548 | -code chooses; this would bring the library to it. | |
| 549 | - | |
| 550 | -The proposal, procedure by procedure, from reading each one: | |
| 551 | - | |
| 552 | -- **To `var`** (it changes what it is given): `Arena.init`, `reset`, | |
| 553 | - `done`; `Buf.init`, `room`, `add`, `str`, `spare`, `cut`, `reset`, | |
| 554 | - `done`, and the `Buf` that `Files.load`, `Files.read`, `Fmt.write`, | |
| 555 | - `Str.join` and `Str.replace` write into; every procedure of `List`; | |
| 556 | - `Lock.take`, `give`; `Map.init`, `put`, `remove`, `done`; the | |
| 557 | - procedures of `Opt` that change the `Parser` (`init`, `next`, | |
| 558 | - `operand`, `scope`, ...); `Sys.openDir`, `nextEntry`, `closeDir`; | |
| 559 | - `Thread.lock`, `unlock`; `Vec.init`, `room`, `push`, `pop`, `add`, | |
| 560 | - `tryPush`, `tryAdd`, `resize`, `reset`, `done`. | |
| 561 | -- **To a value** (it only reads a record of a few words): `Buf.bytes`, | |
| 562 | - `Vec.all`, `Map.get`, `Map.next`, `Sys.entryKind`. | |
| 563 | -- **To `const`** (it only reads a record of many words; part 4): | |
| 564 | - `Opt.at`, and whichever other procedure of `Opt` a reading shows only | |
| 565 | - reads the `Parser`. | |
| 566 | -- **Staying pointers**: an allocator, `^Mem.Allocator`, everywhere | |
| 567 | - (`NEW` takes one, and `^Arena(a)` needs one); `Mem.pages`, `unmap`, | |
| 568 | - `Sys.mmap`, `munmap`, `mapFile`, which are bytes, not variables; | |
| 569 | - `Thread.spawn`'s `arg`, which is kept, and the `^Thread` it gives, | |
| 570 | - which `join` and `signal` take as the program holds it; `Rt.fail`, | |
| 571 | - which the compiler calls. | |
| 572 | - | |
| 573 | -What it costs: it breaks every program that calls these, `src/`, | |
| 574 | -rmacs, ravite, the tools and the library's own tests among them. The | |
| 575 | -mending is mechanical, `ADR(x)` to `var x` at each such call, and `p` | |
| 576 | -to `var p^` where a program holds the thing by pointer, and the | |
| 577 | -compiler's message for a `^T` given to a `var` names it. The seed | |
| 578 | -knows `var` parameters but not the marks of part 1, so with them | |
| 579 | -`src/` and the library it imports wait for the new seed. Alone, this | |
| 580 | -part changes volume 2 and `raz-lib.3`, not the report. | |
| 581 | - | |
| 582 | -Met in rpg and rsqlite, whose `Query`, `Result` and `Stmt` went from | |
| 583 | -`^T` to `var` and to values, and whose own calls to `Buf` couldn't. | |
| 584 | - | |
| 585 | 542 | ### Part 3: marking what a procedure does with what it is given: `ret` and `keep` |
| 586 | 543 | |
| 587 | 544 | #### The hole |
| @@ -870,80 +827,6 @@ | ||
| 870 | 827 | `ret` does. D's experience is that the corners (fields, generics, |
| 871 | 828 | procedure values) take years; the narrow form here leaves record |
| 872 | 829 | lifetimes out, and so the first false alarm above, on purpose. |
| 873 | - | |
| 874 | -### Part 4: a `const` parameter | |
| 875 | - | |
| 876 | -``` | |
| 877 | -proc is*(const sc: Scanner; s: []U8): BOOL; | |
| 878 | -proc text*(ret const sc: Scanner): []U8; | |
| 879 | -``` | |
| 880 | - | |
| 881 | -A `const` parameter is the caller's variable itself, as a `var` one | |
| 882 | -is, and the procedure may only read it: it may not assign it or a | |
| 883 | -part of it, give it to a `var` parameter, nor take its `ADR`. Nothing | |
| 884 | -is copied, whatever its size. Its argument is any expression of the | |
| 885 | -parameter's type: a variable is passed in place; anything else, a | |
| 886 | -call's result, a literal, an expression, goes in a temporary of the | |
| 887 | -statement, and its address is passed. | |
| 888 | - | |
| 889 | -It is passed by its address always, so what it means is plain: if the | |
| 890 | -variable changes while the procedure runs, through a `var` parameter, | |
| 891 | -a pointer or another thread, the procedure sees the change. | |
| 892 | -`f(var x, x)`, with `f`'s second parameter `const`, reads `x` as it now | |
| 893 | -is. (Ada leaves the choice of copy or address to the compiler, and a | |
| 894 | -program that depends on it is wrong; raz fixes the address, which is | |
| 895 | -the cheaper and the one a reader expects.) | |
| 896 | - | |
| 897 | -It is never marked at the call: the procedure neither changes nor | |
| 898 | -keeps what it is given (part 1, rule 8). With it, `STANDARDS.md` says: | |
| 899 | -a record or array only read is a value when it is a few words, and | |
| 900 | -`const` when it is more; `var` is for what is changed. So `var` at a | |
| 901 | -call always means a change, and the marks of part 1 stay true. | |
| 902 | - | |
| 903 | -A `const` parameter whose type holds an array lends the caller's | |
| 904 | -variable to `ret`, as a `var` one does (part 3, "Words"). A procedure | |
| 905 | -type says `const` where its procedure does, and two signatures are | |
| 906 | -alike only if their `const`s are (5.9). A code procedure receives a | |
| 907 | -`const` parameter's address in a register, as a `var` one's; `extern` | |
| 908 | -procedures take none. | |
| 909 | - | |
| 910 | -Met in porting the compiler to raz, where the seed's `const x: TItem` | |
| 911 | -(about 130 bytes) became a value parameter, copied at every call. | |
| 912 | -Measured once the port built: not what stands out, the compiler's | |
| 913 | -profile is flat (`Scan.tokPos` is 9%). Met again here, where `Opt`'s | |
| 914 | -`Parser` and the tools' `Scanner`, many words, are only read by many | |
| 915 | -procedures, and `var` for them would be a mark that isn't true. | |
| 916 | - | |
| 917 | -Costs: the report, 8 and 5.9; the compiler, 30 to 60 lines: the word | |
| 918 | -in a heading, passing as `var` does, the temporary, and the checks | |
| 919 | -above. The seed knows `const` parameters in Pascal, not in raz; `src/` | |
| 920 | -uses them after the new seed, as it does the marks. | |
| 921 | - | |
| 922 | -### Part 5: a constant holds a variant | |
| 923 | - | |
| 924 | -Today a typed constant holds no variant (4: "no variant and no other | |
| 925 | -pointer"), and `src/Parse.raz` says "a constant holds no variant". So a | |
| 926 | -table of `Opt.Row`s, a variant, can't be a constant, and part 3 makes | |
| 927 | -the literal table at `Opt.init`'s call an error. The plain place for | |
| 928 | -such a table is a constant: | |
| 929 | - | |
| 930 | -``` | |
| 931 | -const Rows: []Opt.Row = [ | |
| 932 | - Opt.usage("", "Sh [-c script | file]"), | |
| 933 | - Opt.option("", 'c', "command", "script", "run script, not standard input"), | |
| 934 | - Opt.sub("", "run", "run the file named")]; | |
| 935 | -``` | |
| 936 | - | |
| 937 | -A variant's case built from constants, `Opt.usage("", "...")`, or a | |
| 938 | -case without fields, `dot`, is a constant of the variant's type, and a | |
| 939 | -variant may stand among a constant's elements and fields as a record | |
| 940 | -may. Its bytes are as 5.6 lays them out: the case's number, then its | |
| 941 | -fields, the rest zero. Nothing else changes: a constant is still read | |
| 942 | -only, and a `match` on one works as on a variable. | |
| 943 | - | |
| 944 | -Costs: the report, 4, one line; the compiler, the variant's branch of | |
| 945 | -the constant writer in `Parse.raz`, which writes the tag and the | |
| 946 | -case's fields as it writes a record's: about 20 lines. | |
| 947 | 830 | |
| 948 | 831 | ## A minus sign after an operator |
| 949 | 832 |
| @@ -6,18 +6,21 @@ | ||
| 6 | 6 | do. New code keeps to it; old code comes to it when it is next changed, |
| 7 | 7 | or, for the library's interfaces, at a thaw (`PROPOSALS.md`). |
| 8 | 8 | |
| 9 | -## Parameters: a value, `var`, or a pointer | |
| 9 | +## Parameters: a value, `const`, `var`, or a pointer | |
| 10 | 10 | |
| 11 | -A procedure takes a variable it is given in one of three ways, by what | |
| 11 | +A procedure takes a variable it is given in one of four ways, by what | |
| 12 | 12 | it does with it: |
| 13 | + | |
| 14 | +| The procedure | The parameter | Example | | |
| 15 | +|---|---|---| | |
| 16 | +| reads it, a few words at most (a handle, a slice, a small record) | a value | `Buf.bytes(b: Buf)` | | |
| 17 | +| reads it, more than a few words | `const` | `Opt.number(const p: Parser; lo, hi: I64)` | | |
| 18 | +| changes it, and lets go of it when it returns | `var` | `Buf.add(var b: Buf; c: U8)` | | |
| 19 | +| keeps it past the call, in a record, a module variable or another thread | a pointer, `^T` | `Thread.spawn(p, arg: ^U8)` | | |
| 13 | 20 | |
| 14 | -- **It reads it**: a value, when the type is a few words at most (a | |
| 15 | - handle, a slice, a small record). A larger record or array that is | |
| 16 | - only read is `var`, since a value parameter is a copy (8; a `const` | |
| 17 | - parameter waits in `PROPOSALS.md`). | |
| 18 | -- **It changes it, and lets go of it when it returns**: `var`. | |
| 19 | -- **It keeps it**, in a record, a module variable or another thread, | |
| 20 | - past the call: a pointer, `^T`. | |
| 21 | +A `const` parameter is passed in place, as a `var` one is, so nothing | |
| 22 | +is copied; and since it can't be changed, `var` in a heading always | |
| 23 | +means the procedure changes what it is given. | |
| 21 | 24 | |
| 22 | 25 | So `ADR` at a call says the callee keeps what it is given. A reader |
| 23 | 26 | who sees `Pg.start(q, ADR(c), sql)` knows that `q` is changed and `c` |
| @@ -13,7 +13,7 @@ | ||
| 13 | 13 | This report defines the language. It is short on purpose. Whatever it |
| 14 | 14 | doesn't allow, raz doesn't have. |
| 15 | 15 | |
| 16 | -This is version 2026-10.32 of the report; section 11 says where each | |
| 16 | +This is version 2026-10.33 of the report; section 11 says where each | |
| 17 | 17 | version's changes are told. 2026-10.11 and 2026-10.12 are a thaw the owner chose, |
| 18 | 18 | for a language anyone can build again. They break programs written |
| 19 | 19 | for 2026-10.10 and before: for 2026-10.9, say, the report of compiler |
| @@ -41,7 +41,15 @@ | ||
| 41 | 41 | 5.7); and `continue` (section 7.2), which breaks a program that has a |
| 42 | 42 | name `continue`. 2026-10.32 is an eighth thaw: a constant typed `[]T` |
| 43 | 43 | may be `[]`, the empty slice (section 4); it breaks no program. |
| 44 | +2026-10.33 is a ninth: a `const` parameter, the caller's variable read | |
| 45 | +in place (section 8), and a variant in a constant (section 4), which | |
| 46 | +break no program; and the library's procedures that took a pointer to | |
| 47 | +what they work on take a `var` parameter, a `const` one or a value | |
| 48 | +instead (the library volume), which breaks a program that calls them | |
| 49 | +with `ADR`. | |
| 44 | 50 | |
| 51 | +The compiler follows version 2026-10.32 until the library has moved. | |
| 52 | + | |
| 45 | 53 | The language is frozen, softly, from this version on: it changes only |
| 46 | 54 | to mend a defect, and its library grows only by what breaks no program |
| 47 | 55 | written for it. What anyone wishes it had waits on a list, for a later |
| @@ -358,10 +366,10 @@ | ||
| 358 | 366 | procedure may be declared `forward` and defined later (section 8). |
| 359 | 367 | |
| 360 | 368 | **Constants** are evaluated by the compiler. Their expressions use only |
| 361 | -literals, other constants, operators, conversions, `SIZE` and the `LEN` | |
| 362 | -of arrays and strings. A constant is an integer, a real, a `BOOL`, a | |
| 363 | -name of an enumeration, a set, a string, an array, a record or an | |
| 364 | -`ERROR`. A constant of an integer type wraps as the | |
| 369 | +literals, other constants, operators, conversions, `SIZE`, the `LEN` | |
| 370 | +of arrays and strings, and a variant's cases. A constant is an integer, | |
| 371 | +a real, a `BOOL`, a name of an enumeration, a set, a string, an array, | |
| 372 | +a record, a variant or an `ERROR`. A constant of an integer type wraps as the | |
| 365 | 373 | program would: `U8(250) + 10` is 4. Dividing by zero in a constant is |
| 366 | 374 | an error, and so is dividing the smallest value of a signed type by -1, |
| 367 | 375 | with `div` or `mod`, which stops a program (section 6.1). A string constant can be indexed and sliced as an array of |
| @@ -375,18 +383,21 @@ | ||
| 375 | 383 | w := Text[4..7]; (* "cat" *) |
| 376 | 384 | ``` |
| 377 | 385 | |
| 378 | -A constant with a type is an `ERROR` (section 5.8), an array or a | |
| 379 | -record, and the value of an array or record constant is a literal | |
| 380 | -(section 6.5) of constants. Its elements and fields are integers, | |
| 381 | -reals, `BOOL`s, enumerations, sets, `ERROR`s, procedures, `nil`, a | |
| 382 | -string for a `[]U8`, an array constant or the empty slice for a slice | |
| 383 | -of its element type, and arrays and records of these; no variant and | |
| 384 | -no other pointer: | |
| 386 | +A constant with a type is an `ERROR` (section 5.8), an array, a | |
| 387 | +record or a variant, and the value of an array or record constant is a | |
| 388 | +literal (section 6.5) of constants, that of a variant one a case built | |
| 389 | +from constants, as a program builds one (section 5.6). Its elements | |
| 390 | +and fields are integers, reals, `BOOL`s, enumerations, sets, `ERROR`s, | |
| 391 | +procedures, `nil`, a string for a `[]U8`, an array constant or the | |
| 392 | +empty slice for a slice of its element type, and arrays, records and | |
| 393 | +variants of these; no other pointer. A variant constant must have a | |
| 394 | +type: `const D = dot;` is an error, `const D: Shape = dot;` isn't. | |
| 385 | 395 | |
| 386 | 396 | ``` |
| 387 | 397 | const Primes: [5]I64 = [2, 3, 5, 7, 11]; |
| 388 | 398 | type Rule = record class: []U8; tag: INT; float: BOOL; end; |
| 389 | 399 | const Rules: [2]Rule = [{class: "firefox", tag: 2}, {class: "mpv", float: true}]; |
| 400 | +const Shapes: []Shape = [circle(1.0), rect(2.0, 3.0), dot]; (* Shape of section 5.6 *) | |
| 390 | 401 | ... |
| 391 | 402 | p := Primes[i]; |
| 392 | 403 | ``` |
| @@ -628,9 +639,9 @@ | ||
| 628 | 639 | |
| 629 | 640 | A value of a procedure type is the address of a procedure with that |
| 630 | 641 | signature, as big as an address, or `nil`. Two signatures are alike when |
| 631 | -their parameters have the same types, each `var` or not alike, in order, | |
| 632 | -and their results are the same types; the parameters' names don't | |
| 633 | -matter. | |
| 642 | +their parameters have the same types, each `var`, `const` or neither | |
| 643 | +alike, in order, and their results are the same types; the parameters' | |
| 644 | +names don't matter. | |
| 634 | 645 | |
| 635 | 646 | ### 5.10 Same and assignable |
| 636 | 647 | |
| @@ -1167,8 +1178,9 @@ | ||
| 1167 | 1178 | `match` takes a variant, an enumeration, an integer type (a `U8` |
| 1168 | 1179 | included) or a string, a `[]U8`; other types are an error. It runs the arm of the case `s` holds. An arm may name the case's |
| 1169 | 1180 | fields, in order, all of them; the names stand for those fields of `s` |
| 1170 | -itself, so assigning to one changes `s`; if `s` isn't a variable, they | |
| 1171 | -stand for the fields of a copy. An arm may also leave the fields | |
| 1181 | +itself, so assigning to one changes `s`; if `s` is a constant or a | |
| 1182 | +`const` parameter, they can't be assigned; if `s` isn't a variable, | |
| 1183 | +they stand for the fields of a copy. An arm may also leave the fields | |
| 1172 | 1184 | unnamed. Every case must have an arm, and only one, unless there is an |
| 1173 | 1185 | `| else:` arm, which must come last. |
| 1174 | 1186 | |
| @@ -1404,7 +1416,7 @@ | ||
| 1404 | 1416 | | "var" { ident { "," ident } ":" Type ";" } . |
| 1405 | 1417 | Signature = "(" [ Params { ";" Params } [ ";" "..." ] ] ")" [ ":" Results ] |
| 1406 | 1418 | | [ ":" Results ] . |
| 1407 | -Params = [ "var" ] ident { "," ident } ":" Type . | |
| 1419 | +Params = [ "var" | "const" ] ident { "," ident } ":" Type . | |
| 1408 | 1420 | Results = Type | "(" Type { "," Type } ")" . |
| 1409 | 1421 | ``` |
| 1410 | 1422 | |
| @@ -1418,6 +1430,39 @@ | ||
| 1418 | 1430 | caller's variable itself; its argument must be a variable of exactly |
| 1419 | 1431 | the parameter's type. |
| 1420 | 1432 | |
| 1433 | +A `const` parameter is the caller's variable too, read in place, | |
| 1434 | +whatever its size, with nothing copied; the procedure may only read it. | |
| 1435 | +It may not assign it or a part of it (a field, an element of an array | |
| 1436 | +in it), give it or a part of it to a `var` parameter, take the `ADR` of | |
| 1437 | +either, write it through a view (section 6.9), or assign the names a | |
| 1438 | +`match` arm gives its fields. What a slice or a pointer in it points at | |
| 1439 | +isn't part of it: the procedure may write through them, as it may | |
| 1440 | +through a value parameter's. Its argument is any expression of the | |
| 1441 | +parameter's type: a variable or a constant is passed in place, anything | |
| 1442 | +else as a temporary of the statement, as an array a call returns is | |
| 1443 | +(below). If the variable changes while the procedure runs, through a | |
| 1444 | +`var` parameter, a pointer or another thread, the procedure sees the | |
| 1445 | +change. | |
| 1446 | + | |
| 1447 | +``` | |
| 1448 | +type Parser = record args: [][]U8; at: INT; (* ... *) end; | |
| 1449 | + | |
| 1450 | +proc current(const p: Parser): []U8; (* reads p, many words, in place *) | |
| 1451 | +begin | |
| 1452 | + return p.args[p.at]; | |
| 1453 | +end; | |
| 1454 | + | |
| 1455 | +proc advance(var p: Parser); (* changes p *) | |
| 1456 | +begin | |
| 1457 | + INC(p.at); | |
| 1458 | +end; | |
| 1459 | +``` | |
| 1460 | + | |
| 1461 | +A procedure takes what it reads as a value when it is a few words, and | |
| 1462 | +as `const` when it is more; what it changes, as `var`; and a pointer | |
| 1463 | +only for what it keeps past the call, what may be `nil`, an allocator, | |
| 1464 | +or what C or the system takes. | |
| 1465 | + | |
| 1421 | 1466 | **Results.** A procedure returns nothing, one value, or several. A call |
| 1422 | 1467 | that returns several values can only stand on the right of a multiple |
| 1423 | 1468 | assignment, alone as a statement, or alone after `return` in a |
| @@ -1484,8 +1529,8 @@ | ||
| 1484 | 1529 | instruction the assembler doesn't know. |
| 1485 | 1530 | |
| 1486 | 1531 | It is called like any procedure, with the System V convention: integer |
| 1487 | -and pointer arguments arrive in `rdi`, `rsi`, `rdx`, `rcx`, `r8` and | |
| 1488 | -`r9`, `F32` and `F64` ones in `xmm0` to `xmm7`, and the result goes in | |
| 1532 | +and pointer arguments, and the addresses of `var` and `const` ones, | |
| 1533 | +arrive in `rdi`, `rsi`, `rdx`, `rcx`, `r8` and `r9`, `F32` and `F64` ones in `xmm0` to `xmm7`, and the result goes in | |
| 1489 | 1534 | `rax` (and `rdx` for a second) or `xmm0`. Its parameters and results |
| 1490 | 1535 | are therefore of the types C can take (section 9), or slices, at most |
| 1491 | 1536 | six integer and eight real parameters, and at most two results. A |
| @@ -1591,7 +1636,8 @@ | ||
| 1591 | 1636 | through a checked variable. Dereferencing a stale or made-up pointer, |
| 1592 | 1637 | indexing through a pointer, a slice kept after the call whose frame |
| 1593 | 1638 | holds what it points at (section 7.3), a slice of an array a call |
| 1594 | -returned kept past its statement (section 8), an index out of range in a | |
| 1639 | +returned, or of a temporary given to a `const` parameter, kept past | |
| 1640 | +its statement (section 8), an index out of range in a | |
| 1595 | 1641 | module that says `check off;`, writing a string's bytes, a code procedure that |
| 1596 | 1642 | breaks its rules, and C code can read or write any memory, and what |
| 1597 | 1643 | follows isn't defined. Dereferencing `nil`, dividing |
| @@ -1801,7 +1847,7 @@ | ||
| 1801 | 1847 | | "var" { ident { "," ident } ":" Type ";" } . |
| 1802 | 1848 | Signature = "(" [ Params { ";" Params } [ ";" "..." ] ] ")" [ ":" Results ] |
| 1803 | 1849 | | [ ":" Results ] . |
| 1804 | -Params = [ "var" ] ident { "," ident } ":" Type . | |
| 1850 | +Params = [ "var" | "const" ] ident { "," ident } ":" Type . | |
| 1805 | 1851 | Results = Type | "(" Type { "," Type } ")" . |
| 1806 | 1852 | ExternDeclaration = "extern" ( "proc" IdentDef Signature |
| 1807 | 1853 | | "var" IdentDef ":" Type ) . |
| @@ -198,3 +198,16 @@ | ||
| 198 | 198 | 4). Before, both were errors, since an array has at least one |
| 199 | 199 | element. It breaks no program. `Vec` gains `pop`, and `Sys.Info` |
| 200 | 200 | `links`, how many names a file has (volume 2). |
| 201 | +- **2026-10.33.** A thaw, the ninth. A parameter may be `const`: the | |
| 202 | + caller's variable, read in place with nothing copied, which the | |
| 203 | + procedure may not change; its argument is any expression of its type | |
| 204 | + (sections 5.9, 7.4, 8 and 10). A typed constant may be a variant, or | |
| 205 | + hold variants among its elements and fields, each a case built from | |
| 206 | + constants (section 4). Neither breaks a program. The library's | |
| 207 | + procedures that took a pointer to what they work on, and kept none, | |
| 208 | + take it as a `var` parameter when they change it, as a `const` one or | |
| 209 | + a value when they only read it: `Arena`, `Buf`, `Files.read` and | |
| 210 | + `load`, `Fmt.write`, `List`, `Lock`, `Map`, `Opt`, `Str.join` and | |
| 211 | + `replace`, `Sys`'s directories, `Thread.lock` and `unlock`, `Vec` | |
| 212 | + (volume 2). That breaks a program that calls them with `ADR`; it is | |
| 213 | + mended by writing `x` for `ADR(x)`, and `p^` for a pointer `p`. |