Chapter 39 — Teaching Notes

One-line purpose. Show students that Fortran is alive — a shipped 2023 standard, an open governance process, a rebuilt ecosystem, and a real roadmap — while drilling the one professional habit this chapter exists to teach: separate what has shipped from what is coming, and check compiler support before you rely on a feature.

Key ideas to emphasize

  • The chapter's spine is honesty, not features. The single most valuable takeaway is the discipline: "Fortran 2023 added X" is a fact; "Fortran will have generics" is a forecast; "my gfortran compiles X" is an empirical question you must test. Every feature in §39.1 is taught with a "usable today?" verdict on purpose. Grade students on whether they keep those apart, not on memorized syntax.
  • Conditional expression ≠ merge (§39.1, the load-bearing technical point). merge is a function and evaluates both arguments; the conditional expression short-circuits. The guarded-division / guarded-sqrt example is where this lands — a merge "guard" is not a guard. This is the one idea worth a live demo and a quiz question, because it is a real bug students will otherwise write.
  • The standards process explains backward compatibility (§39.2, the threshold concept). The same committee that adds conditional expressions is why 1970s COMMON code still compiles. "Evolution without breakage" reframes the committee's conservatism as a feature. Tie it explicitly to the Part IV ethic.
  • The ecosystem is the "not dead" argument made concrete (§39.3). fpm + stdlib + Playground + LFortran, built in the open since ~2020. "Interactive Fortran" (LFortran/Playground) is genuinely new — students who have only ever edit-compile-linked will find it striking.
  • Generics is the headline of the future — and it is not here yet (§39.4). Present it as the big coming thing, complementary to Ch. 10's OOP (compile-time type flexibility vs run-time dispatch), and label it proposed. Model the honest framing you want from them.

Misconceptions to preempt

  • "A conditional expression is just nicer merge." (No — it short-circuits; merge evaluates both branches.)
  • "Fortran 2023 shipped, so my compiler supports it." (No — support lags publication, feature by feature.)
  • "The 2023 enumeration type is the same as enum, bind(c)." (No — the 2003 one is named integer constants for C interop; the 2023 one is a distinct, checked type.)
  • "sind is non-standard / won't compile." (It is standardized in 2023 and a long-standing gfortran extension; compile with -std=f2023 and give the pi/180 fallback.)
  • "Generics / seamless GPU offload are in Fortran now." (No — proposed / vendor-specific; not shipped standard behavior.)
  • "One company owns Fortran's direction." (No — an open ISO process; WG5 steers, J3 drafts, anyone may propose.)
  • "LFortran can replace gfortran for my production code today." (No — still maturing; explore/teach with it.)

A live demonstration (10 minutes)

Open the fortran-lang Playground in a browser (no install needed) and: 1. Paste print '(f8.5)', sind(90.0_dp) (or the degree table) — students see 1.00000 appear in the browser. Point out: this is Fortran running with nothing installed, powered by LFortran. 2. Show the merge trap: print *, merge(1.0/x, 0.0, x /= 0.0) with x = 0.0 — discuss why the division still happens (both arguments evaluated) and that an if (or a 2023 conditional expression) fixes it. 3. If LFortran is installed locally, evaluate a couple of statements interactively at its prompt to make "interactive Fortran" concrete. The arc — "it runs in a browser" → "here's the one real bug (merge as a guard)" → "and here's Fortran in a REPL" — lands §39.1 and §39.3 together.

Class-time budget (~50 min)

  • 15 min: §39.1 — conditional expressions (the merge contrast, the demo), enumeration types (the poor-man's enum and why it isn't type-safe), degree trig; keep hammering the "usable today?" column.
  • 10 min: §39.2 — J3/WG5, the ~5-year cadence, backward compatibility (the threshold concept).
  • 10 min: §39.3 — fpm/stdlib recap, the Playground + LFortran live demo.
  • 8 min: §39.4 — generics (proposed!), do concurrent reduce/GPU direction; the honest-forecasting rule.
  • 4 min: Project Checkpoint — the half-sine sind refresh; nx=5 → [0,70.711,100,70.711,0]; keep the fallback.
  • 3 min: spaced review (Ch. 10 & 32) — set as exit questions.

Prerequisites to review

Chapter 1 (the timeline / "dead language" framing this chapter closes), Chapter 16 (fpm, stdlib, LFortran named — the ecosystem this chapter revisits), Chapter 10 (class vs type, dispatch cost — needed for the generics contrast and spaced review), Chapter 32 (coarrays, teams' weak support — spaced review), and the merge intrinsic (Ch. 4/5). If possible, have students open the Playground before class so the demo and the Try-It-Yourself land immediately.

Connections

Back: Ch. 1 (timeline, myth), Ch. 10 (OOP ⇄ generics), Ch. 16 (ecosystem hub), Ch. 32 (coarrays evolving), Ch. 13/6 (defensive code, pure, in the case studies). Forward: Ch. 40 (careers — the living, evolving language is a hiring argument; the solver becomes a portfolio piece). This chapter is the book's forward-look; Ch. 40 is its human close.