This commit is contained in:
10 files changed
+24
-24
No files matched your search
+4
-4
@@ -70,7 +70,7 @@ A rule is `{ id, title, why, docUrl, example, apis, detect }`. The starting rule
|
||||
|
||||
- **Bridge:** the Best practices dock tab lists each finding with the Mojo line, the pseudo line it came from (the hub's line map), the reason, before and after, the manual link, and, where true, how to write the pseudo so the translator writes the better form. Clicking one lights both lines. The Mojo is read-only, so rewrites are shown, not applied. **Show idiomatic version** (in the Mojo tab, off until chosen) shows a copy with the safe rewrites applied, only if it passes the checker no worse than the literal one and the interpreter prints exactly what the literal one prints; it keeps the generated label ("Generated from pseudo, with N best-practice rewrites").
|
||||
- **Developer:** findings are `note` diagnostics with origin "best practices" (never an error or a warning, so they never look like the compiler) in Problems and the gutter, each with a one-click fix where the rewrite is safe. A rule that cannot promise a safe rewrite (`comptime`) explains and leaves the editing to the student.
|
||||
- **Tests** (`core/tests/practices.test.mjs`): every rule's example passes the checker, runs, and prints the same before and after, and the rule's fix turns one into the other; every method a rewrite names is in the harvested index; a false-positive gate runs the rules over Modular's own tested programs in `core/mojo/corpus/manual/` against a reviewed allowlist; each exercise's findings are pinned by a snapshot; applying every fix to each exercise's generated Mojo and each `core/mojo/local/` program keeps it checking and printing the same.
|
||||
- **Tests** (`core/tests/practices.test.mjs`): every rule's example passes the checker, runs, and prints the same before and after, and the rule's fix turns one into the other; every method a rewrite names is in the harvested index; a false-positive gate runs the rules over Modular's own tested programs in `core/library/mojo/corpus/manual/` against a reviewed allowlist; each exercise's findings are pinned by a snapshot; applying every fix to each exercise's generated Mojo and each `core/library/mojo/local/` program keeps it checking and printing the same.
|
||||
|
||||
### Saved versions
|
||||
|
||||
@@ -123,7 +123,7 @@ The **Share** button in the app produces the app link, a ready-to-paste `<iframe
|
||||
- **matho pane**: equations as a source language, written in LaTeX (`core/src/services/matho.ts`). One `FUNCTION` per equation; `\sum` and `\prod` become accumulator loops, subscripts become positions (with the 1-based shift when the sum starts at 1), `\begin{cases}` becomes `IF`/`ELSEIF`, Greek letters become names, references to earlier equations become calls hoisted out of loops when their arguments do not change. Every decision is a note on the equation's line; integrals, infinity, limits and derivatives are refused with the finite procedure to write instead. The trace steps the pseudo with the marker on the equation each step came from.
|
||||
- **Numerics**: `SUM_OF MEAN_OF VARIANCE_OF STDEV_OF MEDIAN_OF DOT NORM_OF FILL CHOOSE RANDN FLOOR CEIL LOG10 SIN COS TAN ATAN2 PI()`, and `PARALLEL FOR`, a loop whose passes may run at once, checked at run time: two passes touching one location stop the run with a data race that names the location and the passes.
|
||||
|
||||
- **Mojo for every exercise with pseudo**: each has its Mojo in `core/mojo/local/`, so the Developer and Hardware areas always have something to show for it; `core/tests/mojo.test.mjs` runs each Mojo program in the interpreter and checks it prints what the exercise expects.
|
||||
- **Mojo for every exercise with pseudo**: each has its Mojo in `core/library/mojo/local/`, so the Developer and Hardware areas always have something to show for it; `core/tests/mojo.test.mjs` runs each Mojo program in the interpreter and checks it prints what the exercise expects.
|
||||
- **Panes**: the area's own (see the table above), dimmed when empty (a dimmed tab opens an empty pane to write in), as tabs over one editor (CodeMirror: search and replace with Ctrl+F, go to line with Ctrl+G, bracket matching, undo and redo; Tab indents, Ctrl+/ comments). The editor is never split: in the Bridge a short note in the pane head says the other tabs update as you type (lingo and matho update the pseudo, and the pseudo the Mojo made from it), and clicking a line marks the lines it became in the next tab down; Hardware does the same between Mojo and x86-64. Drag the dividers to resize (double-click resets); the widths, the dock tab, and what is folded are remembered in the share link.
|
||||
- **The side column** is the inspect panel. Its tabs are offered only when they mean something for the pane (Prove for the pseudo family) and dimmed, with the reason, when the run has nothing for them yet.
|
||||
- **The Run view** (the first tab, in the Bridge and the Developer area; `src/core/runview.ts`, drawn by `src/ui/views/run.ts`) is the whole run read top to bottom, one row per step: its number, its line, what ran (indented by call depth, with what it printed), and a column for each variable you **follow**, holding its value after that step: in color where the step wrote it (with the position, `[5, 6]`, when it wrote one element), faded where it carries over, underlined where the step reads it, hatched where it is not in scope. The lifecycle of the value a variable names (Mojo: made ●, copied ⧉, moved in ⇢, moved out ⇥, destroyed ✕) is marked in the same cell; events of values no column names are noted beside the step. Above the rows, the followed variables as they stand at the stepper's position, with a ruler for a string or list and a grid for a table, the element just written and the one about to be read marked. **+ variables** opens a picker of every variable in the run, by routine; until you choose, it follows the variables of the routine that does the most work. The choice is kept per area (`layout.follow`). "Only steps that change something" hides the rest. Click a row to step there; the stepper keeps its row in view. It replaces the Variables panel, the trace table, the table of values and the Lifetimes tab, which each showed part of this.
|
||||
@@ -149,7 +149,7 @@ Pseudo is the hub: every other notation translates to or from it, so four langua
|
||||
- It never invents Mojo. A line with no faithful spelling (a loop condition that would need such a loop, a built-in the standard library lacks) becomes `raise Error("not translated: pseudo line N")` and a `translate-gap` warning on the pseudo line; the program stops there instead of printing a plausible wrong answer. The pseudo's own mistakes (`unsupported`) are reported, not translated.
|
||||
- Two behaviors differ by design, and a literal translation keeps Mojo's: dividing a `FLOAT` by zero stops the notation but gives `nan` in Mojo, and `PARALLEL FOR` runs its passes in order with no race detector. Translation notes (`translate-divide`, `translate-each-order`, and so on) say so on the line.
|
||||
|
||||
`core/tests/sync-mojo.test.mjs` holds the translation to the pseudo: for every exercise with pseudo and every program in `core/tests/corpus/`, the generated Mojo has no checker errors, runs in the interpreter, and prints what the pseudo prints (compared by value, not text: `TRUE` and `True`, `3` and `3.0`, a map's keys in any order). Programs it cannot hold to that are listed in the test with a reason (the interpreter declines `chr`, `ord`, random numbers and the math functions; the checker is right about the two programs that read an unset variable), and `AGREE_AT_LEAST` is a floor that can only rise. A snapshot of the generated Mojo for every exercise is in `core/tests/snapshots/sync-mojo/`; when a change to the translator is wanted, run the test with `UPDATE_SNAPSHOTS=1` and review the diff.
|
||||
`core/tests/sync-mojo.test.mjs` holds the translation to the pseudo: for every exercise with pseudo and every program in `core/library/pseudo/programs/`, the generated Mojo has no checker errors, runs in the interpreter, and prints what the pseudo prints (compared by value, not text: `TRUE` and `True`, `3` and `3.0`, a map's keys in any order). Programs it cannot hold to that are listed in the test with a reason (the interpreter declines `chr`, `ord`, random numbers and the math functions; the checker is right about the two programs that read an unset variable), and `AGREE_AT_LEAST` is a floor that can only rise. A snapshot of the generated Mojo for every exercise is in `core/tests/snapshots/sync-mojo/`; when a change to the translator is wanted, run the test with `UPDATE_SNAPSHOTS=1` and review the diff.
|
||||
|
||||
**pseudo → lingo** (`core/src/sync/pseudo-to-lingo.ts`) writes the English that the lingo reader (`readSteps` in the course engine's `english.js`) understands, so the lingo pane can follow the pseudo pane. The grammar belongs to the reader, and the translator is held to it: before returning, it reads its own output back and checks that the same routines come out with the same kinds of input. If English cannot say something the way the reader needs it, the result is `unsupported` with a warning on the pseudo line, and the pane keeps its last good text instead of showing English that does not read.
|
||||
|
||||
@@ -193,7 +193,7 @@ Everything is pinned to **Mojo 1.1.0** and checked against the real compiler on
|
||||
|
||||
**Compile & run** (Ctrl+Enter on the Mojo pane) sends the program to godbolt.org in one request: the compiler's answer, the program's output (the input box feeds `input()`), and the listing. The **Compiler** view shows them. The compiler's messages land on their lines with its fix-its as one-click fixes (an implicit copy offers "transferring the value with '^'" or "copy it explicitly with '.copy()'"). The listing is grouped by function, your own first, in Intel syntax translated from godbolt's AT&T (or the original). **Send to x86-64 pane** puts one function, and the functions of yours it calls, on the model machine with its arguments' registers ready and the listing's read-only strings placed in memory; each call into the standard library becomes a stub that stops the run where the real program would enter the library, and says so. `core/docs/asm-coverage.md` is the census of every instruction compiled Mojo uses against what the machine models (everything but 256-bit AVX2), and `core/tests/asm-coverage.test.mjs` keeps it that way. Build "as written" (`-O0`, the default, which keeps every function you wrote) or "optimized" (what `mojo build` does: small functions fold into their callers). An edit after compiling marks the answer stale rather than showing it on the wrong lines. **Step through** runs the Mojo pane in Programming+'s own interpreter (`core/src/mojo/interp.ts`): line by line, with the variables it follows, what each line reads and writes, loop passes, breakpoints, and each value's lifetime, in the Run view. `core/tests/mojo-run.test.mjs` holds it to godbolt: on every program godbolt ran, it prints exactly what that run printed, or declines and says why.
|
||||
|
||||
**An exercise's Mojo** is a program in `core/mojo/local/`, named by the exercise's `mojoProgram`. `corpus.py verify` checks it on godbolt, and the pane's badge says "verified on Mojo 1.1.0" only when godbolt's answer passed the program's own expectation.
|
||||
**An exercise's Mojo** is a program in `core/library/mojo/local/`, named by the exercise's `mojoProgram`. `corpus.py verify` checks it on godbolt, and the pane's badge says "verified on Mojo 1.1.0" only when godbolt's answer passed the program's own expectation.
|
||||
|
||||
**The corpus** behind all of this (the compiler's own words, Modular's tested programs, our probes, and godbolt's stored answers) is described in [mojo-corpus.md](../core/docs/mojo-corpus.md).
|
||||
|
||||
|
||||
Reference in new issue
Block a user