plum
git clone https://git.pyrossh.dev/plum
A statically typed, imperative programming language inspired by rust, python
931d6a7
— Peter John
2026-11-04T21:20:22+05:30
docs: decide Option/Result enums replace error sets, T? and null (run D)
docs/backlog.md
CHANGED
|
@@ -8,7 +8,7 @@ Open work, in the order the user queued it, plus smaller items found during buil
|
|
|
8
8
|
- **Explicit function generics** (user 2026-11-04: right after cleanup phase 2) — functions declare their generics (`fun map[B](...)`) instead of every single capital letter being a generic; allows longer generic names and one-letter concrete types/tags. Grammar change + about 140 signatures in std/examples. Phase 2's "generics by scope" makes this mostly a grammar + signature rewrite.
|
|
9
9
|
- **Io as a built-in primitive with extern methods** (user 2026-11-04: LAST, once the whole compiler refactor and explicit generics are done) — `docs/plans/2026-11-04-io-primitive-extern-methods.review.md`. `primitive Io` with `extern fun f(self, ..)` methods replaces the ~55 top-level externs + forwarding `record Io` methods. A fake/recording `Io` comes later via a trait or language mocks.
|
|
10
10
|
- **Move the Rust code into `compiler/`** (user 2026-11-04: once all the refactoring is done) — every Rust crate (plum-core, plum-checker, plum-wasm-codegen, plum-cli, plum-lsp, plum-host, plum-test-support, plum-runtime, plum-game) goes under `compiler/`; `plum-std` and `plum-examples` stay at the top level. Mechanical but touches hardcoded paths: workspace `Cargo.toml` members, every `CARGO_MANIFEST_DIR/..` repoRoot (test-support, tests, cli), the loader's std lookup, the checker's `isStdFile`/`isIoFile` path tests, `cmdBuild`'s runtime manifest path, plum-game web-test fixtures, scripts/, Makefile.toml, plum-tooling (vscode/tree-sitter paths), README and docs links. Open question for then: keep the `plum-` prefixes inside `compiler/` or drop them (`compiler/core`, …).
|
|
11
|
-
2. **Simplify the language: no traits, no union enums, native inline variants** (decided by the user 2026-11-04; runs right after compiler-cleanup phase 3a, before explicit generics and 3b; decision record §13). Traits are removed as a language feature and replaced by records embedding records with subtyping + `override` dispatch (a `Ship` embedding `Node` is accepted wherever a `Node` is, and calls dispatch to Ship's overrides — the scene graph's `trait Actor` becomes a base record). Union enums (`enum X = A | B` of records) are removed: `JsonParse` and the union examples become inline-variant enums, union syntax becomes an error. Inline variants compile natively as struct subtypes of their enum, deleting `hoistInlineVariants`, the `List__Cons(Cons(..))` wrappers, union forwarders, `union_lower` and the checker's union plan. `unboxed_variants.plum` is a compiler probe: move it to a codegen test. Same plan also covers (user 2026-11-04):
|
|
11
|
+
2. **Simplify the language: no traits, no union enums, native inline variants** (decided by the user 2026-11-04; runs right after compiler-cleanup phase 3a, before explicit generics and 3b; decision record §13). Traits are removed as a language feature and replaced by records embedding records with subtyping + `override` dispatch (a `Ship` embedding `Node` is accepted wherever a `Node` is, and calls dispatch to Ship's overrides — the scene graph's `trait Actor` becomes a base record). Union enums (`enum X = A | B` of records) are removed: `JsonParse` and the union examples become inline-variant enums, union syntax becomes an error. Inline variants compile natively as struct subtypes of their enum, deleting `hoistInlineVariants`, the `List__Cons(Cons(..))` wrappers, union forwarders, `union_lower` and the checker's union plan. `unboxed_variants.plum` is a compiler probe: move it to a codegen test. Same plan also covers (user 2026-11-04): `=` reassign-only, no generators (`fun*`/`yield`; Seq deleted, one loop form `for x := range v` over Int or any `next(self) -> Pair[T, Self]?`), no variadics (`...T`; `[..]` literal → `Cons`/`Nil`, `[k => v]` → `Map.empty().with(..)`), no value enums, `record` merged into `struct` now, and **run D: error sets / `T!E` / `T?` / `null` replaced by std `Option[T]` and `Result[T, E]` enums**, keeping `try`, `?:`, `?.`, `catch`, `T?` and `E!T` as parser sugar (decision record §13). Runs A (in progress), B (struct), C (traits/unions), D (Option/Result).
|
|
12
12
|
3. **Benchmark** before FBIP (user: FBIP waits for it).
|
|
13
13
|
4. **FBIP: no heap mutation** — persistent std collections updated in place when unique, Koka-style `fip` functions as a checked in-place guarantee, a reference count used only as a uniqueness check if static proof falls short. Worklist = the `mut` fields left today (see below). (Decision record §9.)
|
|
14
14
|
5. **One product type, `struct`** — after FBIP, merge `record` into an immutable `struct` with compiler-chosen boxing (optional hint, shown by `--explain`). (Decision record §9b.)
|
docs/decisions/2026-11-language-and-scene-decisions.md
CHANGED
|
@@ -129,7 +129,7 @@ The user decided to simplify the language before the compiler is refactored furt
|
|
|
129
129
|
- **Order:** right after compiler-cleanup phase 3a; then explicit function generics; then cleanup 3b, 4, 5, 6.
|
|
130
130
|
- This supersedes §11's "has traits" and the enum/union split in §8b.
|
|
131
131
|
- **Same plan, also decided 2026-11-04** (user: "1 to 6 all can be done"):
|
|
132
|
-
1.
|
|
132
|
+
1. Errors (revised later the same day, user: "Yes please"): error sets, `T!E` and `T?` as special types are REMOVED in favour of two ordinary std enums, `Option[T] = None | Some(value: T)` and `Result[T, E] = Ok(value: T) | Err(error: E)` with `E` an ordinary enum. `null` is removed (→ `None`). The syntax stays as parser sugar: `T?` → `Option[T]`, `E!T` / `error{..}!T` → `Result[T, E]` (an inline set becomes an ordinary enum), `try e` → early-return on `Err`/`None`, `a ?: b` → `unwrapOr`, `x?.f` → `map`, `catch` → `match`. No automatic error-set merging: different error enums meet through `mapErr`. This reverses the 2026-10-25 move away from Option/Result, deliberately, to remove error-set types and inference from the checker. Runs as run D, after A-C.
|
|
133
133
|
2. `=` only reassigns; `:=` is the only declaration (no declare-on-first-use).
|
|
134
134
|
3. Generators (`fun*`/`yield`) are removed; `Seq` and their std/example users (Seq.plum, Map, Int, List, functional/sequences examples) are rewritten on plain functions/loops.
|
|
135
135
|
4. Variadics `...T` are removed; callers pass a list/slice literal (`List.init`, `Map(...)`).
|