Interactive Textbook — v2 Group highlights · Diagram quizzes · Mobile stack · Authoring sketch

VERSION v2
FIDELITY wireframe
FROM  v1 · Side Panel

Diagrams span paragraphs

One diagram ↔ a group of related paragraphs. Hover/tap any paragraph → its matching components pulse; other paragraphs in the same group get a light tint so you see the scope.

Quiz mode, same diagram

The memory diagrams are reused as assessment: code → diagram (fill the boxes) and diagram → code (fill the code). Lives on dedicated quiz pages inside the chapter.

Mobile = stacked

Side panels don't work on a phone. Mobile inlines the diagram directly under its group, collapses by default, and gives quizzes a dedicated screen.

Authoring stays markdown

Extend Quartz-flavoured markdown with {#group} attrs and a ::: diagram directive. Instructors write prose as normal; the build wires up the interactions.

keys 14
v2 1 · READING
fundamentals-of-computer-science.github.io / ch-2 / data-and-memory
⌘K search
Chapter 2 · Values and Memory
2.1Values live in boxes
Paragraph mode: hover a whole paragraph → its ①②③ group pulses in the diagram. ·Sentence mode (new): hover an individual sentence → only the code line + cell it describes lights up. ·Groups still show as left-border colors in both modes for orientation.
① single value ② copy ③ independence

Before we can talk about variables, we need a word for the things variables hold. A value is a piece of data your program can compute with — a truth, a number, a piece of text. Each value has a type, and the type decides what you can do with it.

The simplest case is a single value type like int. When you write int x = 5;, the compiler reserves a fixed-size slot of memory and labels it x. The literal 5 is written directly into that slot — no indirection, no pointer.

The slot is the box. Its contents are the value. That's the entire mental model for primitive types: box + contents, nothing more.

Now look at the next line. int y = x; copies the value out of x's box into a brand-new box named y. Crucially, no link is drawn between them — each box holds its own independent copy of 5.

This is why int is sometimes called a copy type. Assignment copies; it does not share.

The payoff comes on the third line. y = y + 1; adds one to y — only y's box changes, from 5 to 6. x still holds 5; its box was never touched. That independence is the whole point of copy semantics.

Chapter 4 introduces reference types, which behave differently. For this chapter, every value you create is its own little island, copied on assignment.

Memory — walkthrough of int x=5; int y=x; y=y+1;
0x7ffc005x
0x7ffc046y
0x7ffc005x (still)
0x7ffc0c
int x = 5; // ① box x ← 5 int y = x; // ② copy into y y = y + 1; // ③ only y changes // x is still 5
translation — what the runtime does
int x = 5;
Evaluate 5 → literal: 5
Bind 5 to x → write into box x
int y = x;
Evaluate x → look up x: 5
Bind 5 to y → new box y ← 5
y = y + 1;
Evaluate y + 1 → look up y (5), add 1: 6
Bind 6 to y → overwrite box y
x is never written to → box x still 5

¶ mode hover a paragraph → group pulses across all three panels. — mode hover a sentence → just the steps + line + cell it describes light up.

1.1
1.2
1.3
2.0
2.1 Values
2.1Q
2.2 Bind
2.3 Scope
2.3Q
2.4 Copy
2.5
2Q
concept 5 / 12

Open questions for v3

· Should groups auto-advance as you scroll — pulsing ① then ② then ③ based on reading position?
· In quizzes, do we want partial-credit scoring or strict all-or-nothing?
· Do we want a "reveal all diagrams" printable view for studying offline?
· For diagram → code mode, compile + run in-browser (C# via WebAssembly) or just string-match?

Likely next moves

→ Commit to the {#group} + ::: diagram authoring shape, then prototype against one real chapter.
→ Decide whether quiz state (progress, scores) gets stored locally only or synced to an account.
→ Figure out the diagram vocabulary: memory boxes cover most of Chapters 1–3, but linked lists in Chapter 4 need pointers/arrows.
→ Mid-fi pass on the reading layout with the real typography of your site.

Tweaks