PeaBox Lab › PeaLang › Learn › Chapter 25 › Lesson 2

Part IV — Expert Production Engineering · Chapter 25 · Lesson 2 of 7 · 2 min read

Lesson 2: Interpreter and VM Implementation Boundaries

Lesson level: Expert

Purpose: Engine parity is measured across values, effects, diagnostics, and security. Compilation support and semantic equivalence are separate claims.

Learning Objectives

2.1 Concepts

The interpreter evaluates syntax nodes with runtime environments; the VM executes compiled instructions with its own frames and value operations. Shared intent does not establish identical implementation. For example, Compiler lowers VarDecl through STORE without a separate constant-binding opcode in the shown bytecode model. VM default parameters require literals. Compound property/index assignment lowering and exceptional finally paths also deserve dedicated differential fixtures. Treat these as audit targets, not proven equivalent behavior.

2.2 Annotated Example

Compare a constant reassignment, a block-shadowed name, a closure capture, and a function default in both engines. Record output, returned values, errors, side effects, and resource consumption. A candidate that prints the same final value may still differ in mutation or denied authority. Do not automatically declare one engine correct merely because it is faster.

2.3 Guided Practice

For each feature, write the intended contract before observing either engine. Identify whether a mismatch belongs to compilation, execution, shared helpers, or an underspecified contract.

2.4 Common Mistakes

Do not rely only on successful arithmetic fixtures, compare error text without source context, or silently relax a security invariant to make engines agree.

2.5 Hands-On Lab

Deliverable: Implementation map, minimized fixtures, observed diagnostics, and unresolved discrepancy register.

2.6 Review Questions

Why is identical output insufficient? Which VarDecl lowering deserves review? What limitation applies to VM defaults?

2.7 Applied Challenge

Build a regression fixture for one demonstrated engine discrepancy without inventing a fix. Document expected behavior and block promotion until the contract is resolved.

Lesson Summary

Engine parity is measured across values, effects, diagnostics, and security. Compilation support and semantic equivalence are separate claims.

Lesson status: Draft complete; ready for review.

← Previous Next →