of each subroutine Transitive closure / graph flow algorithm Calling pattern between subroutines need to be known statically ⇒ cannot deal with first-class subroutines Syntactic Interference Control: Reynolds ’78 Method to compute the support set and allow concurrent evaluation when the support sets don’t overlap Cedric Bastin, Manos Koukoutos (EPFL) Polymorphic Effect System May 13, 2015 3 / 26
imperative programming Concurrent analysis Compiler optimization Compile for parallel environments with concurrent scheduling Masking of side effects useful for program writers, compiler writers and language designers improve design and maintenance of iterative programs Cedric Bastin, Manos Koukoutos (EPFL) Polymorphic Effect System May 13, 2015 4 / 26
Second order lambda calculus = polymorphic lambda calculus Λα.λx : α.f (x) Type system: λf : T → S.λx : T.f (x) type : (T → S) → T → S Cedric Bastin, Manos Koukoutos (EPFL) Polymorphic Effect System May 13, 2015 5 / 26
REGION | EFFECT | TYPE 3 layers: expression, descriptors, kinds description δ : kind κ ::= Region ρ : REGION | Effect : EFFECT | Type τ : TYPE The generalized subtype relation on descriptions is defined to correspond to the subset relation on the underlying sets of regions and effects. Cedric Bastin, Manos Koukoutos (EPFL) Polymorphic Effect System May 13, 2015 6 / 26
programming language with effect system MFX = statically scoped Lisp dialect with type and effect system twice = (PLAMBDA (t:Type, e:Effect) (LAMBDA (f:(SUBR (t) e t)) (LAMBDA (x:T) (f(f x))))) twice : (POLY (t:TYPE e:EFFECT) PURE (SUBR (SUBR:(t) e t) PURE (SUBR (t) e t))) Cedric Bastin, Manos Koukoutos (EPFL) Polymorphic Effect System May 13, 2015 7 / 26
of observable side effects A, B e : τ A, B e! Type assignment A : add: A[x ← τ] get: A(x) Kind assignment B : add: B[d ← κ] get: B(d) e = expression τ = type = effect Cedric Bastin, Manos Koukoutos (EPFL) Polymorphic Effect System May 13, 2015 11 / 26
is tagged by the region ρ it belongs to, and the type τ of the value it contains. A region can contain an unlimited number of locations. Stores σ : Loc → Val: mappings from locations to values States e, σ pairs of expression/store Cedric Bastin, Manos Koukoutos (EPFL) Polymorphic Effect System May 13, 2015 16 / 26
on the underlying regions, for corresponding effects with ⊥ = PURE. E.g. ALLOC(r1) (MAXEFFECT (ALLOC (UNION r1 r2)) (WRITE r1)) ALLOC(r1), WRITE(r1), (ALLOC r2) uncomparable TYPE is based on the underlying regions and effects (all form lattices) Cedric Bastin, Manos Koukoutos (EPFL) Polymorphic Effect System May 13, 2015 18 / 26
of a well-formed state preserves or decreases the type and effect descriptions of the state. Cedric Bastin, Manos Koukoutos (EPFL) Polymorphic Effect System May 13, 2015 19 / 26
a region ρ2 if FV (ρ1) ∧ FV (ρ2) = ∅ Theorem (Soundness) Reduction of a well-formed state allocates, reads, and writes only locations that can be reached through the regions specified by its effect. Cedric Bastin, Manos Koukoutos (EPFL) Polymorphic Effect System May 13, 2015 20 / 26
allocates, reads and writes on @red: example!(MAXEFF (READ @red) (WRITE @red) (ALLOC @red)) But this is not visible outside the scope of example @red is private to the expression. Cedric Bastin, Manos Koukoutos (EPFL) Polymorphic Effect System May 13, 2015 21 / 26
e! , and ρ a region in . If ρ / ∈ FV (τ) x ∈ FV (e) → ρ / ∈ A(x) then ρ can be removed from . So in the previous slide, example!PURE Cedric Bastin, Manos Koukoutos (EPFL) Polymorphic Effect System May 13, 2015 22 / 26
of an expression e! cannot have effects not mentioned in . Masking breaks soundness: evaluation of example has effects on @red, although the masked effect is PURE. Solution: evaluate the expression down to a value, and then mask effects. Introduce a private construct, acts as a delimiter. Cedric Bastin, Manos Koukoutos (EPFL) Polymorphic Effect System May 13, 2015 23 / 26
of a well-formed state allocates, reads, and writes only locations that can be reached through the regions specified by its effect or through the private regions of the expression. Cedric Bastin, Manos Koukoutos (EPFL) Polymorphic Effect System May 13, 2015 25 / 26