Lectures onType Theory
Lexical handlers, stack switching, and clue search
appendix sectionrules

Lexical handlers, stack switching, and clue search

This section freezes the three distinct cards used by chapter 34. Identical letters in different cards do not identify their syntactic categories or configuration relations.

Untyped Lexa roots

Lexa configurations and contexts are C=MHKEt. Abbreviate the two stored frames by F(E,x,t):=(E,let x=[] in t),H(L,P,Lenv):=hdl(L,P,Lenv,[]). Then K::=ϵKF(E,x,t)KH(L,Po,Lenv). The three characteristic roots are: MHKElet x=handle Pb with Po under venv in tMHKF(E,x,t)H(L,Po,Lenv)Ebtb,MHKH(L,Po,Lenv)KElet x=raise L v in tMH[Lkcont(Kk)]KEoto,MHKElet x=resume Lk v in tMH[Lkns]KF(E,x,t)KE[xE(v)]t. In the first root, L is fresh, M(Pb)=λ(xenv,xhdl).tb, and Eb=[xenvLenv,xhdlL]. In the second, Kk=H(L,Po,Lenv)KF(E,x,t),M(Po)=λ(xenv,y,k).to,Eo=[xenvLenv,yE(v),kLk], and Lk is fresh. In the third, H(Lk)=cont(K(E,let x=[] in t)). The raise factorization is by identity L; the resume premise requires a continuation cell, not ns.

Salt interface and selected translation

Salt has configurations MHR, words w::=LPins, and the general instruction set in section 34.3. Its selected translation is TLexaSalt(raise v1 v2)Γ=TLexaSalt(v2)Γr2;TLexaSalt(v1)Γr1;call Praise,TLexaSalt(resume v1 v2)Γ=TLexaSalt(v2)Γr2;TLexaSalt(v1)Γr1;call Presume. The ordinary handle trampoline allocates a stack and pushes Po::Lenv::A::exch. Raise exchanges the header’s saved pointer with the current stack top and allocates a one-cell resumption that points to the exchanger. Resume first writes ns to that cell, exchanges stack pointers, and returns on the reinstated stack.

SL/TL clue interface

The 2025 joint typing-and-translation judgment is ΘΔΣΓt:τt. A TL clue and call-site metadata are C=q,F,q::=i^i˚,H=T0;T;¯:F¯. When search crosses a call frame it applies hopperH. The label-parameter case is i:Fj^hopperH(i^,F)=j^,F. Capability and capture cases inspect T and T0, respectively. Their premises require a unique label with the requested effect name, or a unique capability index to continue following. Thus the hopper is partial on arbitrary triples but defined on metadata produced by the selected well-typed translation.

Generalised-continuation card

The λ source has computation types A!E and handler types CδD, where δ{deep,}. Its higher-order CPS target is the untyped two-level calculus with generalised continuation frames θ,χret,χops::κ. The selected translation roots are C[return V]=λκ.app (κ) C[V],C[handleδM with H]=λκ.C[M]@([],Cδ[H]::κ). Deep res retains the handling frame when captured pure frames are prepended. Shallow res restores the captured frame stack without reinstalling the capturing handler. Parameterised handlers extend a frame with the current parameter and translate locally to ordinary deep handlers; this is a fourth card, not a silent identification with either resumption root.

Search the book

Type to search the local edition.