Lectures onType Theory
Region and capability interfaces
appendix sectionrules

Region and capability interfaces

Tofte–Talpin inference has the form TEee:μ,ϕ,ϕ::=ϵ{get(ρ)}{put(ρ)}ϕ1ϕ2. Constants, variables, and sequencing carry effects as follows:

TEcc at ρ:(int,ρ),{put(ρ)}
RI-Const
TE(x)=(τ,ρ)
TExx:(τ,ρ),
RI-Var
TEe1e1:(τ1,ρ1),ϕ1TE,x:(τ1,ρ1)e2e2:μ,ϕ2
TElet x=e1 in e2 endlet x=e1 in e2 end:μ,ϕ1ϕ2
RI-Let

Its delimiter is TEee:μ,ϕρfrv(TE,μ)TEeletregion ρ in e end:μ,ϕ{get(ρ),put(ρ)}RILetregion. The body effect may contain ρ; the rule discharges it.

The capability core uses r::=ρν,C::=ε{r+}{r1}C1C2C. Access and allocation require authority for r; deallocation requires and consumes {r1}. The state judgment combines memory realization, capability satisfiability, and expression typing. Expressions sequence declarations and may halt only after consuming all linear capability:

Ψ;Δ;Γ;CdΔ;Γ;CΨ;Δ;Γ;Ce
Ψ;Δ;Γ;Clet d in e
Cap-LetDec
Ψ;Δ;Γv:intΔC=Cap
Ψ;Δ;Γ;Chalt v
Cap-Halt

The declaration rules are

ρdom(Δ)xdom(Γ)
Ψ;Δ;Γ;Cnewrgn ρ,xΔ,ρ:Rgn;Γ,x:ρ handle;C{ρ1}
Cap-New
Ψ;Δ;Γv:r handleΨ;Δ;Γh at r:τΔCCapC{r+}
Ψ;Δ;Γ;Cx=h at vΔ;Γ,x:τ;C
Cap-Alloc
Ψ;Δ;Γv:τ0,,τn1 at rΔCCapC{r+}0i<n
Ψ;Δ;Γ;Cx=πivΔ;Γ,x:τi;C
Cap-Project
Ψ;Δ;Γv:r handleΔC=CapC{r1}
Ψ;Δ;Γ;Cfreergn vΔ;Γ;C
Cap-Free

The program boundary is M:ΨΨCΨ;;;Ce(M,e)CapProgram. The separate WCM region calculus has ψ::=α{r}ψ1ψ2. Projection records the accessed region, and the region delimiter discharges it only under the displayed scope conditions:

Δ;ΓRe:τ0,,τn1 at r,ψ0i<n
Δ;ΓRπie:τi,ψ{r}
R-Project
Δ,ρ:Rgn;Γ,xρ:ρ handleRe:τ,ψρftv(τ)dom(Δ)xρdom(Γ)
Δ;ΓRletregion ρ,xρ in e:τ,ψ{ρ}
R-Letregion

The named translation has CapOf(α)=α and CapOf({r})={r+}. Its meta-level continuation consumes fresh unique authority with freergn; it introduces no target lambda.

The three source-bounded comparison cards retain their distinct judgments. Cyclic regions add only the pointer covariance rule

γrlongrshort
Δ;γptr(τ,rlong)ptr(τ,rshort)
Cyc-Region-Sub

The L3 card instead types allocation, deallocation, and exchange by

Δ;Γe:τ
Δ;Γnew e:ρ.(Capρτ!Ptrρ)
L3-New
Δ;Γe:ρ.(Capρτ!Ptrρ)
Δ;Γfree e:ρ.τ
L3-Free
Δ;Γ1e1:Capρτ1Δ;Γ2e2:PtrρΔ;Γ3e3:τ3
Δ;Γ1,Γ2,Γ3swap e1 e2 e3:Capρτ3τ1
L3-Swap

Search the book

Type to search the local edition.