Ch06 Discussion
Discussion Guide
Warm-up (think–pair–share, 5 min). "Here are five tasks — mean of a vector, swap two values, area of a circle, write a file, solve Ax=b. For each: function or subroutine, and why?" (Exercise 6.1.) Surfaces the data-flow rule and the honest edge case (a solver could be a function returning an array, but idiomatically is a subroutine because it returns status and often overwrites inputs).
Main discussion (15–20 min).
1. Why enforce intent? Ask: "The compiler already runs; why make me write intent on every argument when
the code works without it?" Draw out: it catches a class of bugs at compile time, documents data flow, and
feeds optimization. Connect to the "safe and fast from one declaration" theme.
2. The interface is a promise. Pose Case Study 2's premise: step will be rewritten many times but its
signature should not change. Ask what decisions made today (intents, optional bc_value, a pure helper)
keep that promise, and what would break it (baking in a grid size; making the boundary mandatory).
3. Recursion vs iteration. Put the naive recursive array-sum (Exercise 6.28) on the board. Ask why it
crashes on 10⁶ elements where a loop does not. Teaches that "the language allows it" ≠ "it is the right
tool," and that stack depth is a real resource.
Group activity (10 min). In pairs, students take the monolith from Case Study 1 (or a fresh 10-line inline kernel you provide) and, on paper, (a) describe each block in one sentence, (b) label it function or subroutine, and (c) assign an intent to every argument of the procedures they would extract — before writing any code. Collect a few and compare the procedure boundaries different pairs drew.
Exit ticket. "Give the correct intent for each argument of subroutine step(field, alpha, dt), and say
why field is not intent(out)." (Checks §6.2 + the project. Expected: field inout, alpha/dt in; not
out because out would discard the current temperatures the update reads.)