From 244f83fe53f14315e4dc2e905a965f9c19e48be2 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Sat, 12 Sep 2026 13:27:27 +0700 Subject: [PATCH] Globals are program state, so they get a section rather than a frame --- DISCUSS.md | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/DISCUSS.md b/DISCUSS.md index 56427c0..3983399 100644 --- a/DISCUSS.md +++ b/DISCUSS.md @@ -21,14 +21,23 @@ the stack, or a separate buffer. The real question is **which** globals. A program has hundreds and a listing of all of them is the backtrace problem again: the thing you want is buried by the thing you don't. -**Direction settled in conversation: per frame, beside the locals.** Opening a frame shows that function's locals *and* -the globals that function references. Each frame answers for itself — frame 0 shows what the innermost function touched, -frame 3 shows what that one touched, and a global appearing in several frames is informative rather than redundant, -because it says the whole chain was working with it. The compiler already knows the reference set per function, so -nothing is guessed and nothing is configured. +**Direction: one Globals section, scoped to the stack.** Per-frame was considered and dropped. The reason is that a +global is not part of a frame — it is program state the frame happened to touch — so nesting it under one implies an +ownership that is not there, and the same name then appears once per frame that reads it. -What this deliberately does not solve: a global nothing in the current frame names but that you still want visible — -the sand grid while stopped in a helper that never mentions it. That is watching, and it is item 10 rather than part of +So: a section of its own, whose contents are the **union of the globals every frame on the current stack references**. +That keeps the compiler doing the choosing (the reference set per function is already known) without repeating anything, +and without falling back to listing all of a program's globals, which is the backtrace problem again. + +Two refinements that came out of the same conversation: + +- **Annotate each entry with which frames touch it.** This recovers what per-frame would have told you — "the whole + chain is reading this" reads differently from "only the innermost one is" — at no cost in duplication. +- **Order by the innermost frame that touches it.** A deep stack makes the union large again, and proximity to the + error is the ordering that puts the likely culprit on top. + +What this deliberately does not solve: a global that nothing on the stack names but that you still want visible — the +sand grid while stopped in a helper that never mentions it. That is watching, and it is item 10 rather than part of this. ## 2. The break buffer should appear by itself