Lectures onType Theory
Swiftlet access discipline
appendix sectionrules

Swiftlet access discipline

The Chapter 49 fragment fixes p::=τinoutτ,r::=xe.fe1[e2],π:Loc{let,var}×Val. Reachability is the reflexive subtree closure acc(π,)={}iacc(π,i) when the value at contains child locations i. Roots named by distinct bindings in the currently accessible frame must have pairwise disjoint accessible sets.

Path typing preserves the qualifier carried by a variable and distinguishes immutable expressions from mutable paths:

Γ(x)=mτ
Δ;Γpathx:mτ
T-Path-Name
Δ;Γe:sΔ(s)(f)=mτ
Δ;Γpathe.f:letτ
T-LetPropRef
Δ;Γpathr:varsΔ(s)(f)=varτ
Δ;Γpathr.f:varτ
T-VarPropRef
Δ;Γe1:[τ]Δ;Γe2:Z
Δ;Γpathe1[e2]:letτ
T-LetElemRef
Δ;Γpathr:var[τ]Δ;Γe:Z
Δ;Γpathr[e]:varτ
T-VarElemRef

Path selection is a separate small-step judgment. Its complete named rules are

η1(x)=π()=mv
Δπ;η;xlvπ;η;m
PSS-Name
Δπ;η;rlvπ;η;r
Δπ;η;r.flvπ;η;r.f
PSS-Struct
m=min(m,mi)π()=m[1,,k]sΔ(s)(fi)=miτi
Δπ;η;m.filvπ;η;im
PSS-Prop
π()=m[1,,k]0c<k
Δπ;η;m[c]lvπ;η;c+1m
PSS-Elem

The access and assignment rules are

Δ;Γpathr:varτ
Δ;Γarg&r:inoutτ
T-Inout
Δ;Γpathr:varτΔ;Γe:τ
Δ;Γr=e:unit
T-Assign

The published access relation is the least reflexive, transitive relation closed by right field/index extension,

&r&r
&r&r.f
Src-Field
&r&r
&r&r[e]
Src-Index

and ¬const(e)¬const(e)&r[e]&r[e]SrcUnknownIndex. It lacks the left closure needed for nested unknown-index descendants. The book therefore uses definition 49.4. It accepts only paths whose array indices are literals, compares components from the root, and requires ijIref¬(aiBaj). Ordinary arguments are recursively copied into mutually fresh callee roots. Access arguments map directly to existing mutable locations, and generated pop drops only copied roots. Rule T-Call carries the book exclusivity premise; ESS-Call carries the resulting physical-disjointness premise in the final store.

Δ;Γe:(p1,,pk)τ(Δ;Γargai:pi)1ikexclusiveB(a1,,ak)
Δ;Γe(a1,,ak):τ
T-Call
{iiIcpy}dom(π)=ijIref.acc(π,i)acc(π,j)=π=π[iletviiIcpy]η=ηλ[xiiiIcpyIref]
Δπ;η;λ(x:p,ηλ,e)(v)π;η,η;e;pop{iiIcpy}
ESS-Call

Assignment reaches the root only when its path has retained the mutable qualifier:

π()=mv0π0=drop(π,v0)π=π0[varv]
Δπ;η;var=v;eπ;η;e
ESS-Assign

Checked downcast succeeds only by τAnyπ()=letvtypeofΔ,π(v)=τcopy(π,v)=(π,v)Δπ;η;box() as τ;eπ;η;v;eESSDowncast. Failure of its concrete-type premise is one of the two runtime-error forms; failure of PSS-Elem’s literal bound is the other.

Search the book

Type to search the local edition.