The blank, and a warning for a dropped result Report 2026-10.14. _ is a symbol of its own, sBlank: _ := e loads a single value, so a volatile one is read, and drops it; MultiAssign skips the results a _ stands for. _ anywhere else says it isn't a name. A call standing on its own that drops results is noted in drops and warned of in order with the rest, with help writing _ := f(...). The 117 drops in lib, examples, tools and the tests now say _ :=, their comments kept in their columns. raz --version says 2026-10.14. Tests: conform/run/Blank, conform/err/BlankName and BlankValue, test/err/Dropped. 7,816 lines of code; bench 1.13M lines/s.
| @@ -86,8 +86,10 @@ | ||
| 86 | 86 | defect, and the library grows only by what breaks no program written |
| 87 | 87 | for it. A wish for more, the owner's or yours, goes on the list in |
| 88 | 88 | `PLAN.md`, for a later thaw; it isn't built. v0.6.0 was such a thaw, |
| 89 | -by the owner's word: report 2026-10.12; the compiler follows 2026-10.13, | |
| 90 | -whose `Sys` writes without waiting, for rat's pastes. Its parser | |
| 89 | +by the owner's word: report 2026-10.12; the compiler follows 2026-10.14, | |
| 90 | +whose `Sys` writes without waiting, for rat's pastes (10.13), and | |
| 91 | +whose blank, `_ := f(x)`, drops a result that is otherwise warned of | |
| 92 | +(10.14), also by the owner's word. Its parser | |
| 91 | 93 | reaches the machine only through `gen.pas`; its steps 5 to 10 await |
| 92 | 94 | the owner's review, and git has them. Keep |
| 93 | 95 | `doc/compiler.md`'s table of lines and its routine names true when the |
| @@ -17,8 +17,4 @@ | ||
| 17 | 17 | ## Wishes, for a later thaw |
| 18 | 18 | |
| 19 | 19 | What the language or the library might have, met while writing raz; |
| 20 | -none is built while the freeze holds. | |
| 21 | - | |
| 22 | -- A warning for a call whose result is dropped. Code drops results on | |
| 23 | - purpose (`SYSCALL`, `Sys.write`; about 40 places in `lib/`), so it | |
| 24 | - needs a way to say so first, such as `_ := f(x)`. | |
| 20 | +none is built while the freeze holds. None waits now. |
| @@ -0,0 +1,7 @@ | ||
| 1 | +module BlankName; | |
| 2 | +proc main*; | |
| 3 | +var _: I64; x: I64; | |
| 4 | +begin | |
| 5 | + x := _; | |
| 6 | +end; | |
| 7 | +end BlankName. |
| @@ -0,0 +1,9 @@ | ||
| 1 | +module BlankValue; | |
| 2 | +import Out; | |
| 3 | +proc main*; | |
| 4 | +var x: I64; | |
| 5 | +begin | |
| 6 | + x := 1; | |
| 7 | + Out.int(_); | |
| 8 | +end; | |
| 9 | +end BlankValue. |
| @@ -26,9 +26,9 @@ | ||
| 26 | 26 | proc main*: INT; |
| 27 | 27 | var i, full: I64; |
| 28 | 28 | begin |
| 29 | - Rt.atExit(first); | |
| 30 | - Rt.atExit(second); | |
| 31 | - Rt.atExit(third); | |
| 29 | + _ := Rt.atExit(first); | |
| 30 | + _ := Rt.atExit(second); | |
| 31 | + _ := Rt.atExit(third); | |
| 32 | 32 | full := 0; |
| 33 | 33 | for i := 1 to 40 do |
| 34 | 34 | if Rt.atExit(nothing) = Rt.Full then INC(full); end; |
| @@ -0,0 +1 @@ | ||
| 1 | +1 4 4 |
| @@ -0,0 +1,24 @@ | ||
| 1 | +module Blank; | |
| 2 | +import Out; | |
| 3 | +var calls: I64; | |
| 4 | +proc pair(a, b: I64): (I64, I64); | |
| 5 | +begin | |
| 6 | + INC(calls); | |
| 7 | + return a, b; | |
| 8 | +end; | |
| 9 | +proc count: I64; | |
| 10 | +begin | |
| 11 | + INC(calls); | |
| 12 | + return calls; | |
| 13 | +end; | |
| 14 | +proc main*; | |
| 15 | +var n, k: I64; | |
| 16 | +begin | |
| 17 | + _ := count(); | |
| 18 | + n, _ := pair(1, 2); | |
| 19 | + _, k := pair(3, 4); | |
| 20 | + _, _ := pair(5, 6); | |
| 21 | + _ := n + k; | |
| 22 | + Out.int(n); Out.str(" "); Out.int(k); Out.str(" "); Out.int(calls); Out.ln; | |
| 23 | +end; | |
| 24 | +end Blank. |
| @@ -29,6 +29,6 @@ | ||
| 29 | 29 | |
| 30 | 30 | begin |
| 31 | 31 | Table.init(ADR(names), Heap.heap); |
| 32 | - Table.put(ADR(names), "rose", red); | |
| 33 | - Table.put(ADR(names), "sky", blue); | |
| 32 | + _ := Table.put(ADR(names), "rose", red); | |
| 33 | + _ := Table.put(ADR(names), "sky", blue); | |
| 34 | 34 | end FirstUse. |
| @@ -0,0 +1,106 @@ | ||
| 1 | +# Stage: the book "Compiling Raz" | |
| 2 | + | |
| 3 | +This is the owner's go-ahead for a new stage: a book, "Compiling Raz", | |
| 4 | +explaining how the raz compiler works. Follow CLAUDE.md's way of working: | |
| 5 | +one commit per step, push it, then stop for review. Don't change the | |
| 6 | +language or the compiler for the book's sake. If the book exposes a bug | |
| 7 | +or a clumsy spot, report it rather than fixing it. | |
| 8 | + | |
| 9 | +## Read first | |
| 10 | +- CLAUDE.md, doc/raz.md (the report), doc/compiler.md, README.md. | |
| 11 | +- src/*.pas, the whole compiler (about 5,000 lines), and enough of lib/ | |
| 12 | + (Rt, Heap, Mem, Thread, Sys) to explain the runtime. | |
| 13 | +- The tiza skill, for drawings. | |
| 14 | + | |
| 15 | +## The reader | |
| 16 | +A working programmer: not good at Pascal, little knowledge of compilers. | |
| 17 | +- Assume they roughly know registers, the stack and memory. Explain only | |
| 18 | + what raz does with them (frames, calling convention, layout). | |
| 19 | +- Introduce compiler ideas (tokens, grammar, generating code while | |
| 20 | + parsing, symbol tables) briefly and in friendly terms where they first | |
| 21 | + appear. | |
| 22 | +- Teach just enough Pascal to read the compiler: one early chapter, then | |
| 23 | + more as features come up. Teach enough raz the same way. | |
| 24 | +- Keep the two languages visibly apart: ```raz and ```pascal code blocks, | |
| 25 | + and say which one is on screen. | |
| 26 | +- Don't explain formats that can be looked up. ELF gets a page on what | |
| 27 | + raz writes and why, plus a pointer to the spec. | |
| 28 | +- Target 40-50k words. | |
| 29 | + | |
| 30 | +## Tone | |
| 31 | +Like Learn You a Haskell and Starting FORTH: tiny steps, talking straight | |
| 32 | +to the reader, every idea shown at once on a real example, drawings that | |
| 33 | +carry meaning. Warm, with an occasional dry aside. Never a joke per | |
| 34 | +paragraph; humor is seasoning. Plain, short sentences. | |
| 35 | + | |
| 36 | +## Mascot: Razmataz | |
| 37 | +A small, very serious creature with a flashy name, which suits a frugal | |
| 38 | +compiler (razzmatazz minus one z). | |
| 39 | +- Its motto, "once is enough", plays on "raz" meaning "one" or "once" in | |
| 40 | + Polish and Russian. Check that the compiler really works in one pass | |
| 41 | + before leaning on this; if it doesn't, find the honest version of the | |
| 42 | + joke. | |
| 43 | +- Razmataz appears in tiza drawings: eating characters in the scanner, | |
| 44 | + stacking boxes in frames, throwing unused code overboard in linking. | |
| 45 | + | |
| 46 | +## Structure | |
| 47 | +Build up gradually, not unit by unit: | |
| 48 | +1. Introduction and a whirlwind tour: compile `exit 42` (or the smallest | |
| 49 | + real program) through every stage, shallowly. | |
| 50 | +2. Enough Pascal (and raz) to follow along. | |
| 51 | +3. One chapter per language feature, followed through scanner, parser, | |
| 52 | + symbols, code generator and machine code: variables and expressions, | |
| 53 | + control flow, procedures and frames, records and arrays, pointers and | |
| 54 | + the heap, strings, modules, defer, C interop, threads. | |
| 55 | +4. Closing chapters: x64 encoding, link (tree shaking, layout), elf, | |
| 56 | + speed (how it reaches 400k lines a second), and where to go next. | |
| 57 | + | |
| 58 | +Refine this order in the outline (step 1). | |
| 59 | + | |
| 60 | +## Format and tooling | |
| 61 | +- Markdown in doc/book/: NN-slug.md per chapter, plus metadata.yaml | |
| 62 | + (title, author Luis, cover). It must read well as plain text. | |
| 63 | +- `make book` builds build/compiling-raz.epub with pandoc. If pandoc gets | |
| 64 | + installed locally, update the desktop guide (see the global | |
| 65 | + CLAUDE.md). | |
| 66 | +- Drawings: .tiza source and a rendered PNG, both committed (CI has no | |
| 67 | + tiza). Every image has a caption that stands on its own in plain text. | |
| 68 | + Use ASCII art in code blocks for diagrams that are really structure | |
| 69 | + (frames, memory layout); those read the same in both formats. | |
| 70 | +- Disassembly is cleaned up: instructions only, the raz source line | |
| 71 | + beside them as a comment, and bytes only where the bytes are the point. | |
| 72 | + Show raw objdump output once, early, next to the cleaned version, and | |
| 73 | + say how to get it. | |
| 74 | +- A checker, written in raz alongside tools/Doc.raz (reuse what exists), | |
| 75 | + run by `make check`. It must: | |
| 76 | + - compile and run every raz example marked as runnable and compare the | |
| 77 | + expected output written in the book; | |
| 78 | + - confirm every quoted Pascal excerpt still matches src/, quoted by | |
| 79 | + unit and routine name, never by line number; | |
| 80 | + - regenerate or verify the cleaned disassembly. | |
| 81 | + The goal: when the compiler changes, `make check` fails rather than | |
| 82 | + the book going quietly wrong. | |
| 83 | +- CI (.github/workflows/): on a push to main that touches doc/book/**, | |
| 84 | + src/** or lib/**, build the epub and replace the file on a standing | |
| 85 | + prerelease tagged `book` (gh release upload --clobber), so the owner | |
| 86 | + has a fixed URL to open on an iPad. Tagged releases also attach that | |
| 87 | + version's epub. | |
| 88 | + | |
| 89 | +## Steps (each one is a commit, then stop for review) | |
| 90 | +1. The outline: doc/book/OUTLINE.md, chapter by chapter, with what each | |
| 91 | + one teaches, its running example, and the drawings planned. | |
| 92 | +2. The tooling: doc/book/ skeleton, `make book`, the checker in | |
| 93 | + `make check`, the CI job. One placeholder chapter proves the pipeline | |
| 94 | + end to end. | |
| 95 | +3. Razmataz's design sheet (tiza) and one sample chapter, the procedures | |
| 96 | + and frames one, to set tone and depth. | |
| 97 | +4. Then one chapter per step, in order. | |
| 98 | + | |
| 99 | +doc/compiler.md stays as it is: the short guide for people changing the | |
| 100 | +compiler. The book can point to it but never replaces it. | |
| 101 | + | |
| 102 | +## Left to the tooling step | |
| 103 | +- How the checker marks runnable examples and quoted excerpts inside | |
| 104 | + Markdown. | |
| 105 | +- Whether the cleaned disassembly comes from the compiler's own line | |
| 106 | + information (`make gdb` suggests it has some) or from objdump. |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | # Reading the raz compiler |
| 2 | 2 | |
| 3 | -The compiler is eleven files of Free Pascal, under 7,800 lines of code. | |
| 3 | +The compiler is eleven files of Free Pascal, under 7,900 lines of code. | |
| 4 | 4 | This guide walks through them in the order they are best read: from the |
| 5 | 5 | characters of a source file to the bytes of an executable. It assumes |
| 6 | 6 | you know the language from `doc/raz.md`, and enough x86-64 to read a |
| @@ -9,13 +9,13 @@ | ||
| 9 | 9 | | File | Lines | Code | What | |
| 10 | 10 | |---|---|---|---| |
| 11 | 11 | | `src/diag.pas` | 310 | 229 | Messages: positions, source excerpts, colour, counts | |
| 12 | -| `src/scan.pas` | 884 | 745 | Symbols, literals, comments, positions | | |
| 12 | +| `src/scan.pas` | 886 | 747 | Symbols, literals, comments, positions | | |
| 13 | 13 | | `src/sym.pas` | 615 | 510 | Types, objects, scopes, layout | |
| 14 | 14 | | `src/chunk.pas` | 276 | 217 | The compiled program: chunks, fixups, line notes | |
| 15 | 15 | | `src/x64.pas` | 1,039 | 870 | The instruction encoder, jumps within a procedure, the assembler | |
| 16 | 16 | | `src/gen.pas` | 1,332 | 1,039 | The stack machine, for x86-64: values, operations, checks, calls, frames | |
| 17 | 17 | | `src/item.pas` | 1,342 | 1,118 | Items: types, constants, variables, operators, conversions, calls | |
| 18 | -| `src/parse.pas` | 2,653 | 2,354 | Declarations, statements, expressions, built-ins, recovery, warnings | | |
| 18 | +| `src/parse.pas` | 2,712 | 2,407 | Declarations, statements, expressions, built-ins, recovery, warnings | | |
| 19 | 19 | | `src/link.pas` | 234 | 180 | Tree shaking, layout, patching, the places | |
| 20 | 20 | | `src/elf.pas` | 435 | 352 | Static and dynamic ELF, symbol table, line numbers | |
| 21 | 21 | | `src/raz.pas` | 197 | 147 | The command line | |
| @@ -418,7 +418,10 @@ | ||
| 418 | 418 | Then statements: `Statement` makes each one a recovery point (below) |
| 419 | 419 | and `OneStatement` dispatches; `IfStatement`, |
| 420 | 420 | `WhileStatement`, `ForStatement` and `MatchStatement` emit their jumps |
| 421 | -with gen's labels. A `match` on an integer reads each arm's | |
| 421 | +with gen's labels. The blank is a symbol of its own, `sBlank`, so | |
| 422 | +no declaration or expression takes it: `_ := e` loads a single value | |
| 423 | +and drops it, and `MultiAssign` skips the results it stands for. A | |
| 424 | +`match` on an integer reads each arm's | |
| 422 | 425 | labels in `IntArm`, which refuses a value in two of them, and tests them |
| 423 | 426 | one after another with `MatchRange`: compares and branches, no jump |
| 424 | 427 | table. `Defer` is worth reading: a deferred statement |
| @@ -489,7 +492,10 @@ | ||
| 489 | 492 | reports what isn't exported, doesn't start with `_`, and was never |
| 490 | 493 | used, or, for a variable, only assigned, and a procedure with results |
| 491 | 494 | that may reach its end (`openEnd`, from `ends`, which each statement |
| 492 | -sets). A generic module's instances | |
| 495 | +sets). The calls that drop results are a third list, `drops`, in | |
| 496 | +order: `CompileFile` notes where the module's own begin, since the | |
| 497 | +instances it makes along the way add theirs and take them back. A | |
| 498 | +generic module's instances | |
| 493 | 499 | share its text, so only the first is warned of. |
| 494 | 500 | |
| 495 | 501 | The built-in procedures are in `Builtin` (and `New_`, `Atomic`): each |
| @@ -606,7 +612,9 @@ | ||
| 606 | 612 | it may reach its end without `return` (`ends`, `parse.pas`): each |
| 607 | 613 | way through its statements must end in a `return`, an `if` with an |
| 608 | 614 | `else`, a `match`, a `while true` or a `repeat ... until false` |
| 609 | - with no `break`. `-Werror` makes each an error. | |
| 615 | + with no `break`. So is a call standing on its own that drops a | |
| 616 | + result (`drops`, kept by `OneStatement` and told by `Dropped`); | |
| 617 | + `_ := f(x)` drops one on purpose. `-Werror` makes each an error. | |
| 610 | 618 | - **Several results** come back through a hidden pointer to the |
| 611 | 619 | caller's slots; a code procedure returns two in rax and rdx. |
| 612 | 620 | - **Reals.** A real constant is held as an F64. An `F32` in a register |
| @@ -9,8 +9,8 @@ | ||
| 9 | 9 | for i := 1 to 3 do |
| 10 | 10 | Out.str("raz says "); Out.int(i); Out.ln; |
| 11 | 11 | Out.flush; |
| 12 | - C.printf("C says %d, %s\n", I32(i * i), "squared"); | |
| 13 | - C.fflush(C.stdout); | |
| 12 | + _ := C.printf("C says %d, %s\n", I32(i * i), "squared"); | |
| 13 | + _ := C.fflush(C.stdout); | |
| 14 | 14 | end; |
| 15 | 15 | end; |
| 16 | 16 |
| @@ -42,7 +42,7 @@ | ||
| 42 | 42 | end; |
| 43 | 43 | total := 0; |
| 44 | 44 | for i := 0 to Workers - 1 do |
| 45 | - C.pthread_join(t[i], nil); | |
| 45 | + _ := C.pthread_join(t[i], nil); | |
| 46 | 46 | total := total + parts[i].sum; |
| 47 | 47 | end; |
| 48 | 48 | Out.str("total "); Out.int(total); Out.ln; |
| @@ -52,18 +52,18 @@ | ||
| 52 | 52 | s := XDefaultScreen(d); |
| 53 | 53 | w := XCreateSimpleWindow(d, XRootWindow(d, s), 0, 0, 320, 80, 1, |
| 54 | 54 | XBlackPixel(d, s), XWhitePixel(d, s)); |
| 55 | - XStoreName(d, w, "raz"); | |
| 56 | - XSelectInput(d, w, ExposureMask + KeyPressMask); | |
| 57 | - XMapWindow(d, w); | |
| 55 | + _ := XStoreName(d, w, "raz"); | |
| 56 | + _ := XSelectInput(d, w, ExposureMask + KeyPressMask); | |
| 57 | + _ := XMapWindow(d, w); | |
| 58 | 58 | repeat |
| 59 | - XNextEvent(d, ^U8(ADR(ev))); | |
| 59 | + _ := XNextEvent(d, ^U8(ADR(ev))); | |
| 60 | 60 | if I32(ev[0]) = Expose then |
| 61 | - XDrawString(d, w, XDefaultGC(d, s), 20, 45, text, I32(LEN(text))); | |
| 61 | + _ := XDrawString(d, w, XDefaultGC(d, s), 20, 45, text, I32(LEN(text))); | |
| 62 | 62 | end; |
| 63 | 63 | until I32(ev[0]) = KeyPress; |
| 64 | 64 | key := ^KeyEvent(ADR(ev)); |
| 65 | 65 | Out.str("key "); Out.int(INT(key^.keycode)); Out.ln; |
| 66 | - XCloseDisplay(d); | |
| 66 | + _ := XCloseDisplay(d); | |
| 67 | 67 | return 0; |
| 68 | 68 | end; |
| 69 | 69 |
| @@ -22,7 +22,7 @@ | ||
| 22 | 22 | (* Gives up l, which the caller holds. *) |
| 23 | 23 | proc give*(l: ^Lock); |
| 24 | 24 | begin |
| 25 | - XCHG(ADR(l^.held), 0); | |
| 25 | + _ := XCHG(ADR(l^.held), 0); | |
| 26 | 26 | end; |
| 27 | 27 | |
| 28 | 28 | (* The module's test, in one thread: taken, given, taken again. *) |
| @@ -101,5 +101,5 @@ | ||
| 101 | 101 | |
| 102 | 102 | begin |
| 103 | 103 | tty := Sys.isTerminal(Sys.stdout); |
| 104 | - Rt.atExit(flush); | |
| 104 | + _ := Rt.atExit(flush); | |
| 105 | 105 | end Out. |
| @@ -107,8 +107,8 @@ | ||
| 107 | 107 | with status 2, as a failed check does. *) |
| 108 | 108 | proc stop*(msg: []U8); |
| 109 | 109 | begin |
| 110 | - Sys.write(Sys.stderr, msg); | |
| 111 | - Sys.write(Sys.stderr, "\n"); | |
| 110 | + _ := Sys.write(Sys.stderr, msg); | |
| 111 | + _ := Sys.write(Sys.stderr, "\n"); | |
| 112 | 112 | exit(2); |
| 113 | 113 | end; |
| 114 | 114 | |
| @@ -152,7 +152,7 @@ | ||
| 152 | 152 | proc say; |
| 153 | 153 | begin |
| 154 | 154 | line[lineLen] := '\n'; |
| 155 | - Sys.write(Sys.stderr, line[0..lineLen + 1]); | |
| 155 | + _ := Sys.write(Sys.stderr, line[0..lineLen + 1]); | |
| 156 | 156 | lineLen := 0; |
| 157 | 157 | end; |
| 158 | 158 | |
| @@ -330,7 +330,7 @@ | ||
| 330 | 330 | ip := q[1] - 1; (* the call, by its return address *) |
| 331 | 331 | bp := q[0]; |
| 332 | 332 | end; |
| 333 | - more(same); | |
| 333 | + _ := more(same); | |
| 334 | 334 | end; |
| 335 | 335 | |
| 336 | 336 | (* Says on standard error the calls under way, from the one that calls |
| @@ -365,8 +365,8 @@ | ||
| 365 | 365 | say; |
| 366 | 366 | calls(at, callerFrame(), true); |
| 367 | 367 | act := {}; (* the signal's default action *) |
| 368 | - SYSCALL(13, sig, ADR(act), 0, 8); (* rt_sigaction *) | |
| 369 | - SYSCALL(62, SYSCALL(39), sig); (* kill(getpid(), sig) *) | |
| 368 | + _ := SYSCALL(13, sig, ADR(act), 0, 8); (* rt_sigaction *) | |
| 369 | + _ := SYSCALL(62, SYSCALL(39), sig); (* kill(getpid(), sig) *) | |
| 370 | 370 | end; |
| 371 | 371 | if what = 0 then |
| 372 | 372 | put("index "); |
| @@ -485,7 +485,7 @@ | ||
| 485 | 485 | var t: [4]INT; i, n, k: INT; p: ^Proc; |
| 486 | 486 | begin |
| 487 | 487 | t := [0, 0, 0, 0]; |
| 488 | - SYSCALL(38, 2, ADR(t), 0); (* setitimer(ITIMER_PROF): no more *) | |
| 488 | + _ := SYSCALL(38, 2, ADR(t), 0); (* setitimer(ITIMER_PROF): no more *) | |
| 489 | 489 | profiling := false; |
| 490 | 490 | n := numSamples; |
| 491 | 491 | if n > MaxSamples then n := MaxSamples; end; |
| @@ -511,15 +511,15 @@ | ||
| 511 | 511 | |
| 512 | 512 | begin |
| 513 | 513 | alt := {sp: ADR(altStack[0]), size: LEN(altStack)}; |
| 514 | - SYSCALL(131, ADR(alt), 0); (* sigaltstack *) | |
| 514 | + _ := SYSCALL(131, ADR(alt), 0); (* sigaltstack *) | |
| 515 | 515 | act := {handler: onSignal, flags: Flags, restorer: sigReturn}; |
| 516 | - SYSCALL(13, SigSegv, ADR(act), 0, 8); (* rt_sigaction *) | |
| 517 | - SYSCALL(13, SigFpe, ADR(act), 0, 8); | |
| 516 | + _ := SYSCALL(13, SigSegv, ADR(act), 0, 8); (* rt_sigaction *) | |
| 517 | + _ := SYSCALL(13, SigFpe, ADR(act), 0, 8); | |
| 518 | 518 | if LEN(Sys.env("RAZ_PROFILE")) > 0 then |
| 519 | 519 | act := {handler: onProf, flags: ProfFlags, restorer: sigReturn}; |
| 520 | - SYSCALL(13, SigProf, ADR(act), 0, 8); | |
| 520 | + _ := SYSCALL(13, SigProf, ADR(act), 0, 8); | |
| 521 | 521 | timerv := [0, 1000, 0, 1000]; (* every millisecond, from one on *) |
| 522 | - SYSCALL(38, 2, ADR(timerv), 0); (* setitimer(ITIMER_PROF) *) | |
| 522 | + _ := SYSCALL(38, 2, ADR(timerv), 0); (* setitimer(ITIMER_PROF) *) | |
| 523 | 523 | profiling := true; |
| 524 | 524 | end; |
| 525 | 525 | end Rt. |
| @@ -156,7 +156,7 @@ | ||
| 156 | 156 | (* Closes the file descriptor fd. *) |
| 157 | 157 | proc close*(fd: INT); |
| 158 | 158 | begin |
| 159 | - SYSCALL(3, fd); | |
| 159 | + _ := SYSCALL(3, fd); | |
| 160 | 160 | end; |
| 161 | 161 | |
| 162 | 162 | (* size bytes of fresh, zeroed memory from the system, a multiple of |
| @@ -172,7 +172,7 @@ | ||
| 172 | 172 | (* Gives back to the system the size bytes at p that mmap gave. *) |
| 173 | 173 | proc munmap*(p: ^U8; size: INT); |
| 174 | 174 | begin |
| 175 | - SYSCALL(11, p, size); | |
| 175 | + _ := SYSCALL(11, p, size); | |
| 176 | 176 | end; |
| 177 | 177 | |
| 178 | 178 | (* Whether the file descriptor fd is a terminal: whether it has a |
| @@ -302,7 +302,7 @@ | ||
| 302 | 302 | (* Closes the directory d that openDir opened. *) |
| 303 | 303 | proc closeDir*(d: ^Dir); |
| 304 | 304 | begin |
| 305 | - SYSCALL(3, d^.fd); | |
| 305 | + _ := SYSCALL(3, d^.fd); | |
| 306 | 306 | end; |
| 307 | 307 | |
| 308 | 308 | (* Puts the terminal on fd into raw mode: no echo, no lines, no signals, |
| @@ -325,7 +325,7 @@ | ||
| 325 | 325 | (* The terminal on fd as rawMode found it. *) |
| 326 | 326 | proc restoreMode*(fd: INT); |
| 327 | 327 | begin |
| 328 | - SYSCALL(16, fd, 5402H, ADR(saved)); | |
| 328 | + _ := SYSCALL(16, fd, 5402H, ADR(saved)); | |
| 329 | 329 | end; |
| 330 | 330 | |
| 331 | 331 | (* The columns and rows of the terminal on fd; 80 by 24 if it doesn't |
| @@ -353,7 +353,7 @@ | ||
| 353 | 353 | proc clock*: I64; |
| 354 | 354 | var t: Timespec; |
| 355 | 355 | begin |
| 356 | - SYSCALL(228, 1, ADR(t)); (* clock_gettime: CLOCK_MONOTONIC *) | |
| 356 | + _ := SYSCALL(228, 1, ADR(t)); (* clock_gettime: CLOCK_MONOTONIC *) | |
| 357 | 357 | return t.sec * 1000000000 + t.nsec; |
| 358 | 358 | end; |
| 359 | 359 | |
| @@ -361,7 +361,7 @@ | ||
| 361 | 361 | proc now*: I64; |
| 362 | 362 | var t: Timespec; |
| 363 | 363 | begin |
| 364 | - SYSCALL(228, 0, ADR(t)); (* clock_gettime: CLOCK_REALTIME *) | |
| 364 | + _ := SYSCALL(228, 0, ADR(t)); (* clock_gettime: CLOCK_REALTIME *) | |
| 365 | 365 | return t.sec * 1000000000 + t.nsec; |
| 366 | 366 | end; |
| 367 | 367 | |
| @@ -396,7 +396,7 @@ | ||
| 396 | 396 | if fd < 0 then return fd; end; |
| 397 | 397 | if serving then |
| 398 | 398 | one := 1; (* so that a server can start again at once *) |
| 399 | - SYSCALL(54, fd, 1, 2, ADR(one), 4); (* setsockopt: SOL_SOCKET, SO_REUSEADDR *) | |
| 399 | + _ := SYSCALL(54, fd, 1, 2, ADR(one), 4); (* setsockopt: SOL_SOCKET, SO_REUSEADDR *) | |
| 400 | 400 | r := SYSCALL(49, fd, a, size); (* bind *) |
| 401 | 401 | if r = 0 then r := SYSCALL(50, fd, 4096); end; (* listen *) |
| 402 | 402 | else |
| @@ -664,7 +664,7 @@ | ||
| 664 | 664 | proc openPty*: INT; |
| 665 | 665 | var a: [4096]U8; fd, unlock: INT; |
| 666 | 666 | begin |
| 667 | - cstr("/dev/ptmx", a); | |
| 667 | + _ := cstr("/dev/ptmx", a); | |
| 668 | 668 | fd := SYSCALL(2, ADR(a), 80102H); (* open: O_RDWR, O_NOCTTY, O_CLOEXEC *) |
| 669 | 669 | if fd < 0 then return fd; end; |
| 670 | 670 | unlock := 0; |
| @@ -803,38 +803,38 @@ | ||
| 803 | 803 | end; |
| 804 | 804 | if argv = nil then return -12; end; (* ENOMEM *) |
| 805 | 805 | all := 0FFFFFFFFFFFFFFFFH; |
| 806 | - SYSCALL(14, 2, ADR(all), ADR(old), 8); (* rt_sigprocmask: SIG_SETMASK *) | |
| 806 | + _ := SYSCALL(14, 2, ADR(all), ADR(old), 8); (* rt_sigprocmask: SIG_SETMASK *) | |
| 807 | 807 | pid := SYSCALL(57); (* fork *) |
| 808 | 808 | if pid = 0 then |
| 809 | 809 | if p.tty # 0 then |
| 810 | - SYSCALL(112); (* setsid *) | |
| 810 | + _ := SYSCALL(112); (* setsid *) | |
| 811 | 811 | fd := SYSCALL(2, ADR(name), 2); (* open, O_RDWR *) |
| 812 | - if (fd < 0) or (SYSCALL(16, fd, 540EH, 0) # 0) then SYSCALL(231, 127); end; (* TIOCSCTTY; exit *) | |
| 813 | - for i := 0 to 2 do SYSCALL(33, fd, i); end; (* dup2 *) | |
| 812 | + if (fd < 0) or (SYSCALL(16, fd, 540EH, 0) # 0) then _ := SYSCALL(231, 127); end; (* TIOCSCTTY; exit *) | |
| 813 | + for i := 0 to 2 do _ := SYSCALL(33, fd, i); end; (* dup2 *) | |
| 814 | 814 | else |
| 815 | - if p.group = -1 then SYSCALL(109, 0, 0); (* setpgid *) | |
| 816 | - elsif p.group # 0 then SYSCALL(109, 0, p.group); | |
| 815 | + if p.group = -1 then _ := SYSCALL(109, 0, 0); (* setpgid *) | |
| 816 | + elsif p.group # 0 then _ := SYSCALL(109, 0, p.group); | |
| 817 | 817 | end; |
| 818 | - if p.foreground then foreground(0, SYSCALL(111)); end; (* getpgrp *) | |
| 818 | + if p.foreground then _ := foreground(0, SYSCALL(111)); end; (* getpgrp *) | |
| 819 | 819 | for i := 0 to 2 do |
| 820 | - if p.fds[i] # 0 then SYSCALL(33, p.fds[i], i); end; (* dup2 *) | |
| 820 | + if p.fds[i] # 0 then _ := SYSCALL(33, p.fds[i], i); end; (* dup2 *) | |
| 821 | 821 | end; |
| 822 | 822 | end; |
| 823 | - if (LEN(p.dir) > 0) and (SYSCALL(80, ADR(dir)) # 0) then SYSCALL(231, 127); end; (* chdir *) | |
| 824 | - SYSCALL(436, 3, 0FFFFFFFFH, 0); (* close_range: every fd from 3 *) | |
| 825 | - for i := 1 to 64 do SYSCALL(13, i, ADR(dfl), 0, 8); end; (* rt_sigaction *) | |
| 826 | - SYSCALL(14, 2, ADR(empty), 0, 8); (* no signal blocked *) | |
| 827 | - SYSCALL(59, ADR(a), argv, argv + (LEN(p.args) + 1)); (* execve *) | |
| 828 | - SYSCALL(231, 127); (* exit *) | |
| 823 | + if (LEN(p.dir) > 0) and (SYSCALL(80, ADR(dir)) # 0) then _ := SYSCALL(231, 127); end; (* chdir *) | |
| 824 | + _ := SYSCALL(436, 3, 0FFFFFFFFH, 0); (* close_range: every fd from 3 *) | |
| 825 | + for i := 1 to 64 do _ := SYSCALL(13, i, ADR(dfl), 0, 8); end; (* rt_sigaction *) | |
| 826 | + _ := SYSCALL(14, 2, ADR(empty), 0, 8); (* no signal blocked *) | |
| 827 | + _ := SYSCALL(59, ADR(a), argv, argv + (LEN(p.args) + 1)); (* execve *) | |
| 828 | + _ := SYSCALL(231, 127); (* exit *) | |
| 829 | 829 | end; |
| 830 | 830 | if (pid > 0) and (p.tty = 0) then |
| 831 | 831 | (* as the program does, for whichever of the two runs first *) |
| 832 | 832 | g := p.group; |
| 833 | 833 | if g = -1 then g := pid; elsif g = 0 then g := SYSCALL(111); end; |
| 834 | - if p.group # 0 then SYSCALL(109, pid, g); end; | |
| 835 | - if p.foreground then foreground(0, g); end; | |
| 834 | + if p.group # 0 then _ := SYSCALL(109, pid, g); end; | |
| 835 | + if p.foreground then _ := foreground(0, g); end; | |
| 836 | 836 | end; |
| 837 | - SYSCALL(14, 2, ADR(old), 0, 8); | |
| 837 | + _ := SYSCALL(14, 2, ADR(old), 0, 8); | |
| 838 | 838 | munmap(^U8(argv), size); |
| 839 | 839 | return pid; |
| 840 | 840 | end; |
| @@ -879,7 +879,7 @@ | ||
| 879 | 879 | end; |
| 880 | 880 | fd := -1; |
| 881 | 881 | if caughtSigs # 0 then fd := sigFd; end; |
| 882 | - SYSCALL(14, 0, ADR(m), 0, 8); (* rt_sigprocmask: SIG_BLOCK *) | |
| 882 | + _ := SYSCALL(14, 0, ADR(m), 0, 8); (* rt_sigprocmask: SIG_BLOCK *) | |
| 883 | 883 | fd := SYSCALL(289, fd, ADR(m), 8, 80800H); (* signalfd4: SFD_NONBLOCK, SFD_CLOEXEC *) |
| 884 | 884 | if fd < 0 then return fd; end; |
| 885 | 885 | caughtSigs := m; |
| @@ -907,13 +907,13 @@ | ||
| 907 | 907 | (* Gives the processor to another thread. *) |
| 908 | 908 | proc yield*; |
| 909 | 909 | begin |
| 910 | - SYSCALL(24); | |
| 910 | + _ := SYSCALL(24); | |
| 911 | 911 | end; |
| 912 | 912 | |
| 913 | 913 | (* Ends the program, at once, with status. *) |
| 914 | 914 | proc exit*(status: INT); |
| 915 | 915 | begin |
| 916 | - SYSCALL(231, status); | |
| 916 | + _ := SYSCALL(231, status); | |
| 917 | 917 | end; |
| 918 | 918 | |
| 919 | 919 | (* The test of programs: one on a pseudo-terminal of 100 by 30 prints |
| @@ -1063,9 +1063,9 @@ | ||
| 1063 | 1063 | if (p = nil) or (p[99] # 0) then exit(2); end; |
| 1064 | 1064 | munmap(p, 100); |
| 1065 | 1065 | (* files and directories *) |
| 1066 | - remove("/tmp/raz-sys-dir/f"); | |
| 1067 | - remove("/tmp/raz-sys-dir/g"); | |
| 1068 | - makeDir("/tmp/raz-sys-dir"); | |
| 1066 | + _ := remove("/tmp/raz-sys-dir/f"); | |
| 1067 | + _ := remove("/tmp/raz-sys-dir/g"); | |
| 1068 | + _ := makeDir("/tmp/raz-sys-dir"); | |
| 1069 | 1069 | fd := create("/tmp/raz-sys-dir/f"); |
| 1070 | 1070 | if (fd < 0) or (write(fd, "abc") # 3) then exit(2); end; |
| 1071 | 1071 | close(fd); |
| @@ -1076,7 +1076,7 @@ | ||
| 1076 | 1076 | if (err # 0) or not i.dir or i.file then exit(2); end; |
| 1077 | 1077 | i, err := info("/dev/null"); |
| 1078 | 1078 | if (err # 0) or i.dir or i.file then exit(2); end; |
| 1079 | - remove("/tmp/raz-sys-link"); | |
| 1079 | + _ := remove("/tmp/raz-sys-link"); | |
| 1080 | 1080 | if symlink("/tmp/raz-sys-dir", "/tmp/raz-sys-link") # 0 then exit(2); end; |
| 1081 | 1081 | i, err := info("/tmp/raz-sys-link"); |
| 1082 | 1082 | if (err # 0) or not i.dir or not i.symlink then exit(2); end; |
| @@ -1084,9 +1084,9 @@ | ||
| 1084 | 1084 | if (err # 0) or (name # "/tmp/raz-sys-dir") then exit(2); end; |
| 1085 | 1085 | name, err := readLink("/tmp/raz-sys-dir"); |
| 1086 | 1086 | if err # -22 then exit(2); end; (* EINVAL: not a link *) |
| 1087 | - remove("/tmp/raz-sys-link"); | |
| 1087 | + _ := remove("/tmp/raz-sys-link"); | |
| 1088 | 1088 | (* open as asked, seek, the mode and the time *) |
| 1089 | - remove("/tmp/raz-sys-dir/h"); | |
| 1089 | + _ := remove("/tmp/raz-sys-dir/h"); | |
| 1090 | 1090 | fd := open("/tmp/raz-sys-dir/h", {writing, creating, exclusive}); |
| 1091 | 1091 | if (fd < 0) or (write(fd, "abc") # 3) then exit(2); end; |
| 1092 | 1092 | close(fd); |
| @@ -1104,7 +1104,7 @@ | ||
| 1104 | 1104 | if chmod("/tmp/raz-sys-dir/h", 1EDH) # 0 then exit(2); end; |
| 1105 | 1105 | i, err := info("/tmp/raz-sys-dir/h"); |
| 1106 | 1106 | if i.mode # 1EDH then exit(2); end; |
| 1107 | - remove("/tmp/raz-sys-dir/h"); | |
| 1107 | + _ := remove("/tmp/raz-sys-dir/h"); | |
| 1108 | 1108 | i, err := info("/no/such/file"); |
| 1109 | 1109 | if err >= 0 then exit(2); end; |
| 1110 | 1110 | if openDir(ADR(d), "/tmp/raz-sys-dir") # 0 then exit(2); end; |
| @@ -1128,7 +1128,7 @@ | ||
| 1128 | 1128 | (* a socket: nothing at a path, then a listener that a connection |
| 1129 | 1129 | makes ready, and a byte from it to the connection *) |
| 1130 | 1130 | if connect("/tmp/raz-no-such-socket") # -2 then exit(2); end; (* ENOENT *) |
| 1131 | - remove("/tmp/raz-sys-socket"); | |
| 1131 | + _ := remove("/tmp/raz-sys-socket"); | |
| 1132 | 1132 | l := listen("/tmp/raz-sys-socket"); |
| 1133 | 1133 | if (l < 0) or (listen("/tmp/raz-sys-socket") # -98) then exit(2); end; (* EADDRINUSE: there already *) |
| 1134 | 1134 | c := connect("/tmp/raz-sys-socket"); |
| @@ -1143,7 +1143,7 @@ | ||
| 1143 | 1143 | if send(c, "x") # -32 then exit(2); end; (* EPIPE, and no SIGPIPE *) |
| 1144 | 1144 | close(c); |
| 1145 | 1145 | close(l); |
| 1146 | - remove("/tmp/raz-sys-socket"); | |
| 1146 | + _ := remove("/tmp/raz-sys-socket"); | |
| 1147 | 1147 | testPrograms; |
| 1148 | 1148 | testNet; |
| 1149 | 1149 | end; |
| @@ -189,7 +189,7 @@ | ||
| 189 | 189 | (* Closes the file descriptor fd. *) |
| 190 | 190 | proc close*(fd: INT); |
| 191 | 191 | begin |
| 192 | - C.close(I32(fd)); | |
| 192 | + _ := C.close(I32(fd)); | |
| 193 | 193 | end; |
| 194 | 194 | |
| 195 | 195 | (* size bytes of fresh, zeroed memory from the system, a multiple of |
| @@ -205,7 +205,7 @@ | ||
| 205 | 205 | (* Gives back to the system the size bytes at p that mmap gave. *) |
| 206 | 206 | proc munmap*(p: ^U8; size: INT); |
| 207 | 207 | begin |
| 208 | - C.munmap(p, UINT(size)); | |
| 208 | + _ := C.munmap(p, UINT(size)); | |
| 209 | 209 | end; |
| 210 | 210 | |
| 211 | 211 | (* Renames old to new, replacing what new names: 0, or minus an errno. *) |
| @@ -321,7 +321,7 @@ | ||
| 321 | 321 | (* Closes the directory d that openDir opened. *) |
| 322 | 322 | proc closeDir*(d: ^Dir); |
| 323 | 323 | begin |
| 324 | - C.closedir(d^.d); | |
| 324 | + _ := C.closedir(d^.d); | |
| 325 | 325 | end; |
| 326 | 326 | |
| 327 | 327 | (* Puts the terminal on fd into raw mode, as cfmakeraw makes it: no |
| @@ -339,7 +339,7 @@ | ||
| 339 | 339 | (* The terminal on fd as rawMode found it. *) |
| 340 | 340 | proc restoreMode*(fd: INT); |
| 341 | 341 | begin |
| 342 | - C.tcsetattr(I32(fd), 0, ADR(saved[0])); | |
| 342 | + _ := C.tcsetattr(I32(fd), 0, ADR(saved[0])); | |
| 343 | 343 | end; |
| 344 | 344 | |
| 345 | 345 | (* The columns and rows of the terminal on fd; 80 by 24 if it doesn't |
| @@ -367,7 +367,7 @@ | ||
| 367 | 367 | proc time(clock: I32): I64; |
| 368 | 368 | var t: Timespec; |
| 369 | 369 | begin |
| 370 | - C.clock_gettime(clock, ^U8(ADR(t))); | |
| 370 | + _ := C.clock_gettime(clock, ^U8(ADR(t))); | |
| 371 | 371 | return t.sec * 1000000000 + t.nsec; |
| 372 | 372 | end; |
| 373 | 373 | |
| @@ -415,7 +415,7 @@ | ||
| 415 | 415 | if fd < 0 then return failed(); end; |
| 416 | 416 | if serving then |
| 417 | 417 | one := 1; (* so that a server can start again at once *) |
| 418 | - C.setsockopt(fd, 1, 2, ^U8(ADR(one)), 4); (* SOL_SOCKET, SO_REUSEADDR *) | |
| 418 | + _ := C.setsockopt(fd, 1, 2, ^U8(ADR(one)), 4); (* SOL_SOCKET, SO_REUSEADDR *) | |
| 419 | 419 | r := C.bind(fd, a, U32(size)); |
| 420 | 420 | if r = 0 then r := C.listen(fd, 4096); end; |
| 421 | 421 | else |
| @@ -423,7 +423,7 @@ | ||
| 423 | 423 | end; |
| 424 | 424 | if r # 0 then |
| 425 | 425 | err := failed(); (* before close can change errno *) |
| 426 | - C.close(fd); | |
| 426 | + _ := C.close(fd); | |
| 427 | 427 | return err; |
| 428 | 428 | end; |
| 429 | 429 | return INT(fd); |
| @@ -614,7 +614,7 @@ | ||
| 614 | 614 | if fd < 0 then return failed(); end; |
| 615 | 615 | if (C.grantpt(fd) # 0) or (C.unlockpt(fd) # 0) then |
| 616 | 616 | err := failed(); |
| 617 | - C.close(fd); | |
| 617 | + _ := C.close(fd); | |
| 618 | 618 | return err; |
| 619 | 619 | end; |
| 620 | 620 | return INT(fd); |
| @@ -745,28 +745,28 @@ | ||
| 745 | 745 | end; |
| 746 | 746 | if argv = nil then return -12; end; (* ENOMEM *) |
| 747 | 747 | for i := 0 to LEN(all) - 1 do all[i] := 0FFFFFFFFFFFFFFFFH; end; |
| 748 | - C.sigprocmask(2, ^U8(ADR(all)), ^U8(ADR(old))); (* SIG_SETMASK *) | |
| 748 | + _ := C.sigprocmask(2, ^U8(ADR(all)), ^U8(ADR(old))); (* SIG_SETMASK *) | |
| 749 | 749 | pid := C.fork(); |
| 750 | 750 | if pid = 0 then |
| 751 | 751 | if p.tty # 0 then |
| 752 | - C.setsid(); | |
| 752 | + _ := C.setsid(); | |
| 753 | 753 | fd := C.open(ADR(name[0]), 2); (* O_RDWR *) |
| 754 | 754 | if (fd < 0) or (C.ioctl(fd, TIOCSCTTY, 0) # 0) then C._exit(127); end; |
| 755 | - for i := 0 to 2 do C.dup2(fd, I32(i)); end; | |
| 755 | + for i := 0 to 2 do _ := C.dup2(fd, I32(i)); end; | |
| 756 | 756 | else |
| 757 | - if p.group = -1 then C.setpgid(0, 0); | |
| 758 | - elsif p.group # 0 then C.setpgid(0, I32(p.group)); | |
| 757 | + if p.group = -1 then _ := C.setpgid(0, 0); | |
| 758 | + elsif p.group # 0 then _ := C.setpgid(0, I32(p.group)); | |
| 759 | 759 | end; |
| 760 | - if p.foreground then C.tcsetpgrp(0, C.getpgrp()); end; | |
| 760 | + if p.foreground then _ := C.tcsetpgrp(0, C.getpgrp()); end; | |
| 761 | 761 | for i := 0 to 2 do |
| 762 | - if p.fds[i] # 0 then C.dup2(I32(p.fds[i]), I32(i)); end; | |
| 762 | + if p.fds[i] # 0 then _ := C.dup2(I32(p.fds[i]), I32(i)); end; | |
| 763 | 763 | end; |
| 764 | 764 | end; |
| 765 | 765 | if (LEN(p.dir) > 0) and (C.chdir(ADR(dir[0])) # 0) then C._exit(127); end; |
| 766 | - C.close_range(3, 0FFFFFFFFH, 0); (* every fd from 3 *) | |
| 767 | - for i := 1 to 64 do C.sigaction(I32(i), ^U8(ADR(dfl)), nil); end; | |
| 768 | - C.sigprocmask(2, ^U8(ADR(empty)), nil); | |
| 769 | - C.execve(ADR(a[0]), argv, argv + (LEN(p.args) + 1)); | |
| 766 | + _ := C.close_range(3, 0FFFFFFFFH, 0); (* every fd from 3 *) | |
| 767 | + for i := 1 to 64 do _ := C.sigaction(I32(i), ^U8(ADR(dfl)), nil); end; | |
| 768 | + _ := C.sigprocmask(2, ^U8(ADR(empty)), nil); | |
| 769 | + _ := C.execve(ADR(a[0]), argv, argv + (LEN(p.args) + 1)); | |
| 770 | 770 | C._exit(127); |
| 771 | 771 | end; |
| 772 | 772 | err := failed(); |
| @@ -774,10 +774,10 @@ | ||
| 774 | 774 | (* as the program does, for whichever of the two runs first *) |
| 775 | 775 | g := p.group; |
| 776 | 776 | if g = -1 then g := INT(pid); elsif g = 0 then g := INT(C.getpgrp()); end; |
| 777 | - if p.group # 0 then C.setpgid(pid, I32(g)); end; | |
| 778 | - if p.foreground then C.tcsetpgrp(0, I32(g)); end; | |
| 777 | + if p.group # 0 then _ := C.setpgid(pid, I32(g)); end; | |
| 778 | + if p.foreground then _ := C.tcsetpgrp(0, I32(g)); end; | |
| 779 | 779 | end; |
| 780 | - C.sigprocmask(2, ^U8(ADR(old)), nil); | |
| 780 | + _ := C.sigprocmask(2, ^U8(ADR(old)), nil); | |
| 781 | 781 | munmap(^U8(argv), size); |
| 782 | 782 | if pid < 0 then return err; end; |
| 783 | 783 | return INT(pid); |
| @@ -818,7 +818,7 @@ | ||
| 818 | 818 | e := C.__errno_location(); |
| 819 | 819 | saved := e^; (* as the code it stopped left it *) |
| 820 | 820 | b[0] := U8(sig); |
| 821 | - C.write(sigWrite, ADR(b[0]), 1); | |
| 821 | + _ := C.write(sigWrite, ADR(b[0]), 1); | |
| 822 | 822 | e^ := saved; |
| 823 | 823 | end; |
| 824 | 824 | |
| @@ -873,7 +873,7 @@ | ||
| 873 | 873 | (* Gives the processor to another thread. *) |
| 874 | 874 | proc yield*; |
| 875 | 875 | begin |
| 876 | - C.sched_yield(); | |
| 876 | + _ := C.sched_yield(); | |
| 877 | 877 | end; |
| 878 | 878 | |
| 879 | 879 | (* Ends the program, at once, with status. *) |
| @@ -1029,9 +1029,9 @@ | ||
| 1029 | 1029 | if (p = nil) or (p[99] # 0) then exit(2); end; |
| 1030 | 1030 | munmap(p, 100); |
| 1031 | 1031 | (* files and directories *) |
| 1032 | - remove("/tmp/raz-sys-dir/f"); | |
| 1033 | - remove("/tmp/raz-sys-dir/g"); | |
| 1034 | - makeDir("/tmp/raz-sys-dir"); | |
| 1032 | + _ := remove("/tmp/raz-sys-dir/f"); | |
| 1033 | + _ := remove("/tmp/raz-sys-dir/g"); | |
| 1034 | + _ := makeDir("/tmp/raz-sys-dir"); | |
| 1035 | 1035 | fd := create("/tmp/raz-sys-dir/f"); |
| 1036 | 1036 | if (fd < 0) or (write(fd, "abc") # 3) then exit(2); end; |
| 1037 | 1037 | close(fd); |
| @@ -1042,7 +1042,7 @@ | ||
| 1042 | 1042 | if (err # 0) or not i.dir or i.file then exit(2); end; |
| 1043 | 1043 | i, err := info("/dev/null"); |
| 1044 | 1044 | if (err # 0) or i.dir or i.file then exit(2); end; |
| 1045 | - remove("/tmp/raz-sys-link"); | |
| 1045 | + _ := remove("/tmp/raz-sys-link"); | |
| 1046 | 1046 | if symlink("/tmp/raz-sys-dir", "/tmp/raz-sys-link") # 0 then exit(2); end; |
| 1047 | 1047 | i, err := info("/tmp/raz-sys-link"); |
| 1048 | 1048 | if (err # 0) or not i.dir or not i.symlink then exit(2); end; |
| @@ -1050,9 +1050,9 @@ | ||
| 1050 | 1050 | if (err # 0) or (name # "/tmp/raz-sys-dir") then exit(2); end; |
| 1051 | 1051 | name, err := readLink("/tmp/raz-sys-dir"); |
| 1052 | 1052 | if err # -22 then exit(2); end; (* EINVAL: not a link *) |
| 1053 | - remove("/tmp/raz-sys-link"); | |
| 1053 | + _ := remove("/tmp/raz-sys-link"); | |
| 1054 | 1054 | (* open as asked, seek, the mode and the time *) |
| 1055 | - remove("/tmp/raz-sys-dir/h"); | |
| 1055 | + _ := remove("/tmp/raz-sys-dir/h"); | |
| 1056 | 1056 | fd := open("/tmp/raz-sys-dir/h", {writing, creating, exclusive}); |
| 1057 | 1057 | if (fd < 0) or (write(fd, "abc") # 3) then exit(2); end; |
| 1058 | 1058 | close(fd); |
| @@ -1070,7 +1070,7 @@ | ||
| 1070 | 1070 | if chmod("/tmp/raz-sys-dir/h", 1EDH) # 0 then exit(2); end; |
| 1071 | 1071 | i, err := info("/tmp/raz-sys-dir/h"); |
| 1072 | 1072 | if i.mode # 1EDH then exit(2); end; |
| 1073 | - remove("/tmp/raz-sys-dir/h"); | |
| 1073 | + _ := remove("/tmp/raz-sys-dir/h"); | |
| 1074 | 1074 | i, err := info("/no/such/file"); |
| 1075 | 1075 | if err >= 0 then exit(2); end; |
| 1076 | 1076 | if openDir(ADR(d), "/tmp/raz-sys-dir") # 0 then exit(2); end; |
| @@ -1094,7 +1094,7 @@ | ||
| 1094 | 1094 | (* a socket: nothing at a path, then a listener that a connection |
| 1095 | 1095 | makes ready, and a byte from it to the connection *) |
| 1096 | 1096 | if connect("/tmp/raz-no-such-socket") # -2 then exit(2); end; (* ENOENT *) |
| 1097 | - remove("/tmp/raz-sys-socket"); | |
| 1097 | + _ := remove("/tmp/raz-sys-socket"); | |
| 1098 | 1098 | l := listen("/tmp/raz-sys-socket"); |
| 1099 | 1099 | if (l < 0) or (listen("/tmp/raz-sys-socket") # -98) then exit(2); end; (* EADDRINUSE: there already *) |
| 1100 | 1100 | c := connect("/tmp/raz-sys-socket"); |
| @@ -1109,7 +1109,7 @@ | ||
| 1109 | 1109 | if send(c, "x") # -32 then exit(2); end; (* EPIPE, and no SIGPIPE *) |
| 1110 | 1110 | close(c); |
| 1111 | 1111 | close(l); |
| 1112 | - remove("/tmp/raz-sys-socket"); | |
| 1112 | + _ := remove("/tmp/raz-sys-socket"); | |
| 1113 | 1113 | testPrograms; |
| 1114 | 1114 | testNet; |
| 1115 | 1115 | end; |
| @@ -76,7 +76,7 @@ | ||
| 76 | 76 | begin |
| 77 | 77 | t := ^Thread(arg); |
| 78 | 78 | alt := {sp: ^U8(t) - Alt, size: Alt}; |
| 79 | - SYSCALL(131, ADR(alt), 0); (* sigaltstack *) | |
| 79 | + _ := SYSCALL(131, ADR(alt), 0); (* sigaltstack *) | |
| 80 | 80 | t^.fn(t^.arg); |
| 81 | 81 | end; |
| 82 | 82 | |
| @@ -114,7 +114,7 @@ | ||
| 114 | 114 | tid := ADR(t^.tid); |
| 115 | 115 | v := tid^; |
| 116 | 116 | while v # 0 do |
| 117 | - futex(ADR(t^.tid), FutexWait, v); | |
| 117 | + _ := futex(ADR(t^.tid), FutexWait, v); | |
| 118 | 118 | v := tid^; |
| 119 | 119 | end; |
| 120 | 120 | base := t^.base; |
| @@ -129,7 +129,7 @@ | ||
| 129 | 129 | if CAS(ADR(m^.state), 0, 1) then return; end; |
| 130 | 130 | c := XCHG(ADR(m^.state), 2); |
| 131 | 131 | while c # 0 do |
| 132 | - futex(ADR(m^.state), FutexWait + Private, 2); | |
| 132 | + _ := futex(ADR(m^.state), FutexWait + Private, 2); | |
| 133 | 133 | c := XCHG(ADR(m^.state), 2); |
| 134 | 134 | end; |
| 135 | 135 | end; |
| @@ -139,8 +139,8 @@ | ||
| 139 | 139 | proc unlock*(m: ^Mutex); |
| 140 | 140 | begin |
| 141 | 141 | if XADD(ADR(m^.state), -1) # 1 then |
| 142 | - XCHG(ADR(m^.state), 0); | |
| 143 | - futex(ADR(m^.state), FutexWake + Private, 1); | |
| 142 | + _ := XCHG(ADR(m^.state), 0); | |
| 143 | + _ := futex(ADR(m^.state), FutexWake + Private, 1); | |
| 144 | 144 | end; |
| 145 | 145 | end; |
| 146 | 146 |
| @@ -91,6 +91,12 @@ | ||
| 91 | 91 | stray: boolean; { an "end" in this procedure stood left of its statement's line } |
| 92 | 92 | strayAt: TPos; { ... the first such statement } |
| 93 | 93 | elseIf: boolean; { an "else if" in this procedure } |
| 94 | + drops: array[0..4095] of record | |
| 95 | + at: TPos; { a call standing on its own that drops results } | |
| 96 | + n: longint; { ... how many } | |
| 97 | + end; | |
| 98 | + numDrops: longint; { the module being compiled has those from its | |
| 99 | + first one, saved by CompileFile, to here } | |
| 94 | 100 | ends: boolean; { the statements just read never go on past |
| 95 | 101 | their end: each way through them returns } |
| 96 | 102 | useAt: TPos; { ... which is here } |
| @@ -105,6 +111,7 @@ | ||
| 105 | 111 | { A missing symbol is reported just after the one before it. } |
| 106 | 112 | procedure Expected(const what: shortstring); |
| 107 | 113 | begin |
| 114 | + if tok = sBlank then Mark('_ isn''t a name: it is the blank, which stands only left of :='); | |
| 108 | 115 | MarkAt(MissingPos, 'expected ' + what + ', found ' + Found); |
| 109 | 116 | end; |
| 110 | 117 | |
| @@ -1497,22 +1504,31 @@ | ||
| 1497 | 1504 | |
| 1498 | 1505 | { a, b := f(x): the variables first, left to right, then the call; |
| 1499 | 1506 | then each result to its variable, in order. } |
| 1500 | -procedure MultiAssign(var x: TItem; first: longint); | |
| 1501 | -var d: array[0..15] of TItem; dn: array[0..15] of longint; y, z: TItem; n, i: longint; called: boolean; f: PObj; | |
| 1507 | +procedure MultiAssign(var x: TItem; first: longint; blank: boolean); | |
| 1508 | +var | |
| 1509 | + d: array[0..15] of TItem; dn: array[0..15] of longint; blanks: array[0..15] of boolean; | |
| 1510 | + y, z: TItem; n, i: longint; called: boolean; f: PObj; | |
| 1502 | 1511 | begin |
| 1503 | 1512 | n := 0; |
| 1504 | 1513 | d[0] := x; |
| 1505 | 1514 | dn[0] := first; |
| 1515 | + blanks[0] := blank; | |
| 1506 | 1516 | repeat |
| 1507 | - NotReadOnly(d[n]); | |
| 1508 | - Assignable(d[n], dn[n]); | |
| 1509 | - Pin(d[n]); | |
| 1517 | + if not blanks[n] then begin | |
| 1518 | + NotReadOnly(d[n]); | |
| 1519 | + Assignable(d[n], dn[n]); | |
| 1520 | + Pin(d[n]); | |
| 1521 | + end; | |
| 1510 | 1522 | inc(n); |
| 1511 | 1523 | if tok <> sComma then break; |
| 1512 | 1524 | if n > High(d) then Mark('more than ' + IntStr(High(d) + 1) + ' variables in one assignment'); |
| 1513 | 1525 | Next; |
| 1514 | - dn[n] := id; | |
| 1515 | - LeftSide(d[n], called); | |
| 1526 | + blanks[n] := tok = sBlank; | |
| 1527 | + if blanks[n] then Next | |
| 1528 | + else begin | |
| 1529 | + dn[n] := id; | |
| 1530 | + LeftSide(d[n], called); | |
| 1531 | + end; | |
| 1516 | 1532 | until false; |
| 1517 | 1533 | Expect(sBecomes); |
| 1518 | 1534 | Designator(y, called); |
| @@ -1520,10 +1536,12 @@ | ||
| 1520 | 1536 | MarkAt(y.pos, 'expected a call with ' + IntStr(n) + ' results'); |
| 1521 | 1537 | f := y.typ^.fields; |
| 1522 | 1538 | for i := 0 to n - 1 do begin |
| 1523 | - z := y; | |
| 1524 | - Field(z, f); | |
| 1525 | - CoerceExact(z, d[i].typ, 'several results go to variables of just their types'); | |
| 1526 | - Assign(d[i], z); | |
| 1539 | + if not blanks[i] then begin | |
| 1540 | + z := y; | |
| 1541 | + Field(z, f); | |
| 1542 | + CoerceExact(z, d[i].typ, 'several results go to variables of just their types'); | |
| 1543 | + Assign(d[i], z); | |
| 1544 | + end; | |
| 1527 | 1545 | f := f^.next; |
| 1528 | 1546 | end; |
| 1529 | 1547 | end; |
| @@ -1589,7 +1607,7 @@ | ||
| 1589 | 1607 | Expression(y, x.typ); |
| 1590 | 1608 | Assign(x, y); |
| 1591 | 1609 | end else if tok = sComma then |
| 1592 | - MultiAssign(x, first) | |
| 1610 | + MultiAssign(x, first, false) | |
| 1593 | 1611 | else if not called then begin |
| 1594 | 1612 | if (x.mode = mProc) or ((x.mode in [mVar, mStack]) and (x.typ^.form = fProc)) then begin |
| 1595 | 1613 | BeginCall(c, x); |
| @@ -1598,7 +1616,27 @@ | ||
| 1598 | 1616 | end else if tok = sEql then |
| 1599 | 1617 | MarkHelp(x.pos, Subject(x, first) + ' isn''t a statement', 'assignment is written :=') |
| 1600 | 1618 | else MarkAt(x.pos, Subject(x, first) + ' isn''t a statement'); |
| 1601 | - end else Discard(x); | |
| 1619 | + end else begin | |
| 1620 | + if (x.mode <> mNone) and (numDrops <= High(drops)) then begin | |
| 1621 | + drops[numDrops].at := x.pos; | |
| 1622 | + if x.typ^.tuple then drops[numDrops].n := x.typ^.len else drops[numDrops].n := 1; | |
| 1623 | + inc(numDrops); | |
| 1624 | + end; | |
| 1625 | + Discard(x); | |
| 1626 | + end; | |
| 1627 | + end; | |
| 1628 | + sBlank: begin | |
| 1629 | + Next; | |
| 1630 | + if tok = sComma then MultiAssign(x, 0, true) | |
| 1631 | + else begin | |
| 1632 | + Expect(sBecomes); | |
| 1633 | + Expression(x, nil); | |
| 1634 | + { evaluated and dropped: a single value is loaded, so that a | |
| 1635 | + volatile one is read } | |
| 1636 | + if (x.mode in [mType, mBuiltin, mNone, mCase]) or (x.mode <> mStr) and not IsAggregate(x.typ) then | |
| 1637 | + Value(x); | |
| 1638 | + Discard(x); | |
| 1639 | + end; | |
| 1602 | 1640 | end; |
| 1603 | 1641 | sIf: IfStatement(start, Indent); |
| 1604 | 1642 | sWhile: WhileStatement(start, Indent); |
| @@ -2225,19 +2263,38 @@ | ||
| 2225 | 2263 | Help('if it must be there, call it _' + NameOf(o^.name)); |
| 2226 | 2264 | end; |
| 2227 | 2265 | |
| 2266 | +{ Warns of the call at p, which drops its n results } | |
| 2267 | +procedure Dropped(const p: TPos; n: longint); | |
| 2268 | +var s, blanks: shortstring; i: longint; | |
| 2269 | +begin | |
| 2270 | + s := Source(p); | |
| 2271 | + i := Pos('(', s); | |
| 2272 | + if i > 0 then s := copy(s, 1, i - 1); | |
| 2273 | + blanks := '_'; | |
| 2274 | + for i := 2 to n do blanks := blanks + ', _'; | |
| 2275 | + if n = 1 then Warning(p, 'the result of ' + s + ' is dropped') | |
| 2276 | + else Warning(p, 'the results of ' + s + ' are dropped'); | |
| 2277 | + Help('if that is meant, write ' + blanks + ' := ' + s + '(...)'); | |
| 2278 | +end; | |
| 2279 | + | |
| 2228 | 2280 | { The warnings of module m, by where each declaration is: its own |
| 2229 | - declarations and its procedures' are two lists, each in order. The | |
| 2281 | + declarations and its procedures' are two lists, each in order, and | |
| 2282 | + firstDrop on are the calls that drop results. The | |
| 2230 | 2283 | instances of a generic module share its text, and so its warnings: |
| 2231 | 2284 | only the first is warned of. } |
| 2232 | -procedure Warnings(m: PModule); | |
| 2233 | -var a, b: PObj; n: PModule; | |
| 2285 | +procedure Warnings(m: PModule; firstDrop: longint); | |
| 2286 | +var a, b: PObj; n: PModule; i: longint; | |
| 2234 | 2287 | begin |
| 2235 | 2288 | n := firstModule; |
| 2236 | 2289 | while (n <> nil) and (n^.name <> m^.name) do n := n^.next; |
| 2237 | 2290 | if n <> nil then exit; |
| 2238 | 2291 | a := m^.first; b := m^.locals; |
| 2239 | - while (a <> nil) or (b <> nil) do | |
| 2240 | - if (b = nil) or (a <> nil) and (a^.pos.a < b^.pos.a) then begin | |
| 2292 | + i := firstDrop; | |
| 2293 | + while (a <> nil) or (b <> nil) or (i < numDrops) do | |
| 2294 | + if (i < numDrops) and ((a = nil) or (drops[i].at.a < a^.pos.a)) and ((b = nil) or (drops[i].at.a < b^.pos.a)) then begin | |
| 2295 | + Dropped(drops[i].at, drops[i].n); | |
| 2296 | + inc(i); | |
| 2297 | + end else if (b = nil) or (a <> nil) and (a^.pos.a < b^.pos.a) then begin | |
| 2241 | 2298 | Warn(a); |
| 2242 | 2299 | a := a^.link; |
| 2243 | 2300 | end else begin |
| @@ -2268,8 +2325,9 @@ | ||
| 2268 | 2325 | st: TScanState; saved: array[0..MaxDepth - 1] of longint; d: longint; |
| 2269 | 2326 | oldMod: PModule; oldCheck, oldChecks: boolean; m: PModule; |
| 2270 | 2327 | lib: PLib; start: TPos; alias, mname, line, oldPath: longint; o: PObj; body: longint; iargs: TArgs; |
| 2271 | - generic: boolean; argsAt: TScanState; why: shortstring; | |
| 2328 | + generic: boolean; argsAt: TScanState; why: shortstring; firstDrop: longint; | |
| 2272 | 2329 | begin |
| 2330 | + firstDrop := numDrops; | |
| 2273 | 2331 | SaveScan(st); |
| 2274 | 2332 | SaveScopes(d, saved); |
| 2275 | 2333 | oldMod := curModule; oldCheck := checkMode; oldPath := curFile; oldChecks := checks; |
| @@ -2394,7 +2452,8 @@ | ||
| 2394 | 2452 | if (o^.cls = oProc) and o^.fwd then Error(TokPos, NameOf(o^.name) + ' is declared forward but never defined'); |
| 2395 | 2453 | o := o^.link; |
| 2396 | 2454 | end; |
| 2397 | - if (errors = 0) and not checkOnly then Warnings(m); | |
| 2455 | + if (errors = 0) and not checkOnly then Warnings(m, firstDrop); | |
| 2456 | + numDrops := firstDrop; | |
| 2398 | 2457 | if errors > 0 then Finish; { a module with errors stops the compiler after it } |
| 2399 | 2458 | CloseScope; |
| 2400 | 2459 | m^.done := true; |
| @@ -34,7 +34,7 @@ | ||
| 34 | 34 | { what git describe says, made by make: 0.3.0 at the tag v0.3.0, |
| 35 | 35 | 0.3.0-5-g38d29a8 five commits past it } |
| 36 | 36 | Version = {$I version.inc}; |
| 37 | - Report = '2026-10.13'; { the version of doc/raz.md it follows } | |
| 37 | + Report = '2026-10.14'; { the version of doc/raz.md it follows } | |
| 38 | 38 | MemfdCreate = 319; { the system call; FPC 3.2.2 has no name for it } |
| 39 | 39 | MfdCloexec = 1; { an ELF still executes: the kernel opens it first } |
| 40 | 40 |
| @@ -24,6 +24,7 @@ | ||
| 24 | 24 | sPlus, sMinus, sTimes, sSlash, sEql, sNeq, sLss, sLeq, sGtr, sGeq, |
| 25 | 25 | sBecomes, sColon, sSemicolon, sComma, sPeriod, sUpto, sEllipsis, |
| 26 | 26 | sLparen, sRparen, sLbrak, sRbrak, sLbrace, sRbrace, sArrow, sAmp, sTilde, sBar, |
| 27 | + sBlank, | |
| 27 | 28 | { the reserved words, in the order of Words below } |
| 28 | 29 | sAnd, sBegin, sBreak, sBy, sCode, sConst, sDefer, sDiv, sDo, sElse, |
| 29 | 30 | sElsif, sEnd, sExtern, sFor, sForward, sIf, sImport, sIn, sLink, |
| @@ -106,10 +107,10 @@ | ||
| 106 | 107 | 'in', 'link', 'match', 'mod', 'module', 'not', 'of', 'or', 'packed', |
| 107 | 108 | 'proc', 'record', 'repeat', 'return', 'set', 'shl', 'shr', 'then', |
| 108 | 109 | 'to', 'type', 'until', 'var', 'variant', 'VOLATILE', 'while', 'xor'); |
| 109 | - Ops: array[sPlus..sBar] of string[3] = ( | |
| 110 | + Ops: array[sPlus..sBlank] of string[3] = ( | |
| 110 | 111 | '+', '-', '*', '/', '=', '#', '<', '<=', '>', '>=', |
| 111 | 112 | ':=', ':', ';', ',', '.', '..', '...', |
| 112 | - '(', ')', '[', ']', '{', '}', '^', '&', '~', '|'); | |
| 113 | + '(', ')', '[', ']', '{', '}', '^', '&', '~', '|', '_'); | |
| 113 | 114 | |
| 114 | 115 | var |
| 115 | 116 | cur: TScanState; { buf .. path; tok, ival, rval and id live above } |
| @@ -311,7 +312,7 @@ | ||
| 311 | 312 | { How an operator or reserved word is written, quoted, for messages. } |
| 312 | 313 | function SymText(s: TSym): shortstring; |
| 313 | 314 | begin |
| 314 | - if s in [sPlus..sBar] then SymText := '"' + Ops[s] + '"' | |
| 315 | + if s in [sPlus..sBlank] then SymText := '"' + Ops[s] + '"' | |
| 315 | 316 | else SymText := '"' + Words[ord(s) - ord(sAnd)] + '"'; |
| 316 | 317 | end; |
| 317 | 318 | |
| @@ -777,7 +778,8 @@ | ||
| 777 | 778 | until not (cur.buf[cur.pos] in ['A'..'Z', 'a'..'z', '0'..'9', '_']); |
| 778 | 779 | if cur.pos - start > MaxIdent then LexError('a name has at most ' + IntStr(MaxIdent) + ' characters'); |
| 779 | 780 | h := Intern(@cur.buf[start], cur.pos - start); |
| 780 | - if h < NumWords then tok := TSym(ord(sAnd) + h) | |
| 781 | + if (cur.pos - start = 1) and (c = '_') then tok := sBlank | |
| 782 | + else if h < NumWords then tok := TSym(ord(sAnd) + h) | |
| 781 | 783 | else begin tok := sIdent; id := h end; |
| 782 | 784 | end; |
| 783 | 785 | '0'..'9': Number; |
| @@ -0,0 +1 @@ | ||
| 1 | +-Werror |
| @@ -0,0 +1,9 @@ | ||
| 1 | +test/err/Dropped.raz:9:5: error: the result of Sys.write is dropped | |
| 2 | + 9 | Sys.write(Sys.stdout, "a\n"); | |
| 3 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 4 | +help: if that is meant, write _ := Sys.write(...) | |
| 5 | +test/err/Dropped.raz:10:5: error: the results of pair are dropped | |
| 6 | + 10 | pair(); | |
| 7 | + | ^^^^^^ | |
| 8 | +help: if that is meant, write _, _ := pair(...) | |
| 9 | +raz: 2 errors |
| @@ -0,0 +1,14 @@ | ||
| 1 | +module Dropped; | |
| 2 | +import Sys; | |
| 3 | +proc pair: (I64, I64); | |
| 4 | +begin | |
| 5 | + return 1, 2; | |
| 6 | +end; | |
| 7 | +proc main*; | |
| 8 | +begin | |
| 9 | + Sys.write(Sys.stdout, "a\n"); | |
| 10 | + pair(); | |
| 11 | + _ := Sys.write(Sys.stdout, "b\n"); | |
| 12 | + _, _ := pair(); | |
| 13 | +end; | |
| 14 | +end Dropped. |
| @@ -3,7 +3,7 @@ | ||
| 3 | 3 | |
| 4 | 4 | proc main*; |
| 5 | 5 | begin |
| 6 | - C.printf("%d\n", Bare.f()); | |
| 6 | + _ := C.printf("%d\n", Bare.f()); | |
| 7 | 7 | end; |
| 8 | 8 | |
| 9 | 9 | end Static. |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/BlankName.raz:3:5: error: _ isn't a name: it is the blank, which stands only left of := | |
| 2 | + 3 | var _: I64; x: I64; | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -0,0 +1,4 @@ | ||
| 1 | +conform/err/BlankValue.raz:7:13: error: _ isn't a name: it is the blank, which stands only left of := | |
| 2 | + 7 | Out.int(_); | |
| 3 | + | ^ | |
| 4 | +raz: 1 error |
| @@ -46,7 +46,7 @@ | ||
| 46 | 46 | 1, 2, 3, 4, 5, 6, 7, "eight", 3.14159, 0.5); |
| 47 | 47 | Out.str(buf[0..I64(n)]); Out.ln; |
| 48 | 48 | |
| 49 | - setenv("RAZ_TEST", "yes", 1); | |
| 49 | + _ := setenv("RAZ_TEST", "yes", 1); | |
| 50 | 50 | Out.int(I64(strlen(getenv("RAZ_TEST")))); Out.ln; |
| 51 | 51 | e := environ; |
| 52 | 52 | i := 0; |
| @@ -57,8 +57,8 @@ | ||
| 57 | 57 | Out.int(I64(optind)); Out.ln; |
| 58 | 58 | |
| 59 | 59 | Out.flush; |
| 60 | - C.printf("printf %d %s %.1f\n", -42, "too", 2.5); | |
| 61 | - C.fflush(C.stdout); | |
| 60 | + _ := C.printf("printf %d %s %.1f\n", -42, "too", 2.5); | |
| 61 | + _ := C.fflush(C.stdout); | |
| 62 | 62 | Out.str("done\n"); |
| 63 | 63 | end; |
| 64 | 64 |
| @@ -69,7 +69,7 @@ | ||
| 69 | 69 | Out.int(a[1]); Out.str(" "); Out.int(g.b); Out.ln; |
| 70 | 70 | q, r := minmax(9, 3); |
| 71 | 71 | Out.int(q); Out.int(r); Out.ln; |
| 72 | - divmod(1, 1); | |
| 72 | + _, _ := divmod(1, 1); | |
| 73 | 73 | i, e := nothing(); |
| 74 | 74 | Out.int(i); if e = nil then Out.str(" zero"); end; Out.ln; |
| 75 | 75 | i := 5; |
| @@ -35,8 +35,8 @@ | ||
| 35 | 35 | proc show(name: ^U8; x: F64); |
| 36 | 36 | begin |
| 37 | 37 | Out.flush; |
| 38 | - C.printf("%s %.9g\n", name, x); | |
| 39 | - C.fflush(C.stdout); | |
| 38 | + _ := C.printf("%s %.9g\n", name, x); | |
| 39 | + _ := C.fflush(C.stdout); | |
| 40 | 40 | end; |
| 41 | 41 | |
| 42 | 42 | proc main*; |
| @@ -77,8 +77,8 @@ | ||
| 77 | 77 | show("mix", mix(1.5, 2, 0.25, 0.125)); |
| 78 | 78 | for i := 0 to 3 do arr[i] := F32(i) * 0.5; end; |
| 79 | 79 | show("arr", F64(arr[3])); |
| 80 | - C.printf("%f %f\n", F64(arr[1]), 0.5); | |
| 81 | - C.fflush(C.stdout); | |
| 80 | + _ := C.printf("%f %f\n", F64(arr[1]), 0.5); | |
| 81 | + _ := C.fflush(C.stdout); | |
| 82 | 82 | end; |
| 83 | 83 | |
| 84 | 84 | end Single. |
| @@ -21,7 +21,7 @@ | ||
| 21 | 21 | Thread.lock(ADR(m)); |
| 22 | 22 | INC(count); |
| 23 | 23 | Thread.unlock(ADR(m)); |
| 24 | - XADD(ADR(atomic), 1); | |
| 24 | + _ := XADD(ADR(atomic), 1); | |
| 25 | 25 | NEW(p, Heap.heap); |
| 26 | 26 | p^.next := list; |
| 27 | 27 | list := p; |
| @@ -12,7 +12,7 @@ | ||
| 12 | 12 | |
| 13 | 13 | proc work(_arg: ^U8); |
| 14 | 14 | begin |
| 15 | - down(0); | |
| 15 | + _ := down(0); | |
| 16 | 16 | end; |
| 17 | 17 | |
| 18 | 18 | proc main*; |
| @@ -178,7 +178,7 @@ | ||
| 178 | 178 | exp := name(); |
| 179 | 179 | stop := toSemicolon(); |
| 180 | 180 | next; |
| 181 | - if is("forward") then toSemicolon(); | |
| 181 | + if is("forward") then _ := toSemicolon(); | |
| 182 | 182 | else skipBody; |
| 183 | 183 | end; |
| 184 | 184 | declaration("", exp, start, ds, de, stop); |
| @@ -235,7 +235,7 @@ | ||
| 235 | 235 | if is("const") or is("type") or is("var") then section; |
| 236 | 236 | elsif is("proc") then procedure; |
| 237 | 237 | elsif is("extern") then external; |
| 238 | - elsif is("import") or is("link") then toSemicolon(); next; | |
| 238 | + elsif is("import") or is("link") then _ := toSemicolon(); next; | |
| 239 | 239 | else next; |
| 240 | 240 | end; |
| 241 | 241 | end; |
| @@ -29,7 +29,7 @@ | ||
| 29 | 29 | state := 88172645463325252; |
| 30 | 30 | for i := 0 to LEN(s) - 1 do state := state * 31 + U64(s[i]); end; |
| 31 | 31 | if state = 0 then state := 1; end; |
| 32 | - for i := 1 to 10 do random(2); end; | |
| 32 | + for i := 1 to 10 do _ := random(2); end; | |
| 33 | 33 | end; |
| 34 | 34 | |
| 35 | 35 | (* The symbols that aren't comments. *) |