From first demand to cached reuse

A single-threaded lazy runtime uses call-by-need. Establishing a binding creates a record holding its delayed expression. After successful evaluation, the runtime replaces that expression with its computed value.


The program below executes its two emit operations in the written order. Each operation demands the complete value of its argument. decode(packet) is deterministic, terminates successfully and has no side effects.


Plain text
let summary = decode(packet)
emit(summary)
emit(summary)


Order the events from establishing the binding through satisfying the second demand.

Loading ordering steps…

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Lazy Evaluation Questions: