diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-19 16:03:52 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-19 16:41:06 -0300 |
| commit | d0e36bb453526af64349a4eb2335b86c94bea56d (patch) | |
| tree | 7481782dd321033ece1995372aaaec95830a8f0d /core/panes.zig | |
| parent | 8fea4ab90a04acd5f20528b00342c23d42f8c83e (diff) | |
| download | pardes-d0e36bb453526af64349a4eb2335b86c94bea56d.tar.gz pardes-d0e36bb453526af64349a4eb2335b86c94bea56d.zip | |
core: a pane's slot and a view's slot are two types, `Pane.Id` and `View.Id` (P21, pardes-ids change 1; the user, reading the tape's inputs: "why the id is an u8 though?", and "the id to be typed too"): each a distinct non-exhaustive `enum(u8)` (`pub const Id` inside `Pane` in core/panes.zig and inside `Pardes.View` in core/Core.zig, side by side with the thing whose slot it is), with the one conversion each way the boundary needs, named once: `Id.at(i)` the id of a slot the core holds (`@fromBackingInt(@intCast(i))`, so a slot past a byte panics in a safe build) and `id.index()` the slot as a `u8` (which widens to the `usize` half the core indexes with, so no caller casts); nothing uses them yet; one test at the end of core/views.zig, "a pane's id and a view's id are two types: neither is taken for the other, nor for an integer" (an enum coerces only into itself, so it shows the two are distinct, a byte each and non-exhaustive, and every slot round-trips; a probe that assigned a `View.Id` to a `Pane.Id` failed to compile with "expected type 'panes.Pane.Id', found 'Core.View.Id'"); 46 lines added in three files, no line changed; nothing a step runs is touched, so the frame and perf gate was not run on it and the semantics word does not move (313a99190b93a8c5); gate (load 5 to 10, a drat build beside): tui core-test 841/984 (143 skipped), shell-test 1020/1023, gui unit-test 1618/1622 (the perf check's BaselineHarnessMismatch, the base's 1617/1621 with it), each the base's plus this test
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/panes.zig')
| -rw-r--r-- | core/panes.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/core/panes.zig b/core/panes.zig index cdc28dba..dd36839a 100644 --- a/core/panes.zig +++ b/core/panes.zig @@ -38,6 +38,21 @@ pub const Pane = struct { // it there). .alloc = .{ .{ "addon", "image" }, .{ "pdf", "image" }, .{ "terminal", "terminal" } }, }; + /// A pane's slot in `Pardes.panes`, as it crosses the core's edge: an + /// entry's argument or answer, an event's, an effect's, a host call's. + /// A type of its own, so a view's slot (`View.Id`) is not taken for + /// it; the core's own loops and tables keep their integers. + pub const Id = enum(u8) { + _, + /// The id of slot `i`, a slot the core holds. + pub fn at(i: usize) Id { + return @fromBackingInt(@intCast(i)); + } + /// The slot, to index the core's tables with. + pub fn index(id: Id) u8 { + return @backingInt(id); + } + }; /// The words that throw unsaved text away (builtins.zig warnModified). pub const Discarding = enum { Exit, Restore, get, Del, Delcol }; |
