Week 20 of 145 · Crafting Interpreters

Crafting Interpreters, chapter 22

2 tasks, 6 steps. Open a task's steps to see exactly what to do; each guide has the detail.

Sign up or sign in to tick these off and give this week a due date.

By the end of this week you can

  • Implement locals as stack slots tracked by the compiler.
  • Trace endScope as it pops the locals of a finished block.
  • Explain why locals are much faster to reach than globals.

Week 20 · Self-check

Three quick questions

Ungraded, and it never holds anything up. Pick an answer to see why.

  1. How many OP_POP instructions does endScope emit for { var a = 1; var b = 2; }?
  2. How does the compiler mark a local that is declared but not yet initialized?
  3. At most how many locals can be in scope at once in one clox function?

Nothing is saved while signed out.

Watch along

Free talks and lectures that go with this week, on the speakers' own channels. Optional.

Discussion

0 posts

Stuck on week 20, or finished early? Say what you tried and what happened. Hints over answers: full solutions go in a spoiler.

No posts yet. Ask a question or share a tip.

Sign in to postAnyone can read. Posting needs an account with a confirmed email.

Spot a mistake? Report it