Lune

POPL2026Top-tier venue

Handling Scope Checks: A Comparative Framework for Dynamic Scope Extrusion Checks

Michael Lee, Ningning Xie, Oleg Kiselyov, Jeremy Yallop

2026Year
3Citations
1Top-tier citations

Abstract

Metaprogramming and effect handlers interact in unexpected, and sometimes undesirable, ways. One example is scope extrusion: the generation of ill-scoped code. Scope extrusion can either be preemptively prevented, via static type systems, or retroactively detected, via dynamic checks. Static type systems exist in theory, but struggle with a range of implementation and usability problems in practice. In contrast, dynamic checks exist in practice (e.g. in MetaOCaml), but are understudied in theory. Designers of metaprogramming languages are thus given little guidance regarding the design and implementation of checks. We present the first formal study of dynamic scope extrusion checks, introducing a calculus (𝜆 ⟨ ⟨op⟩ ⟩ ) for describing and evaluating checks. Further, we introduce a novel dynamic check -the "Cause-for-Concern" check -which we prove correct, characterise without reference to its implementation, and argue combines the advantages of existing dynamic checks. Finally, we extend our framework with refined environment classifiers, which statically prevent scope extrusion, and compare their expressivity with the dynamic checks.

CCS Concepts: • Software and its engineering → Control structures.

Ask about this paper

Your agent reads all of it.

Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.

Questions to start from

Your agent calls

Luneget_paper_fulltext

Ask in Lune

Free to start. No credit card required.

lune papers fulltext 1f5fb722-fe83-442e-9d11-71519efe7d76

Cited by top-tier papers1

Ask how each one uses it

Builds on5

Related papers

Dusk over the sea between two cliffs drawn in fine vertical lines