Comparing Universes and Existential Ownership Types Nicholas Cameron Werner Dietl ETH Zurich Victoria University of Wellington
Ownership
● Structure the heap into a hierarchy ● Enforce this structure statically ● Many ways to implement this idea ● Topology (description) vs encapsulation
Ownership Types ● Ownership information presented using context parameters class C { C f1; C f2; } – Clarke, Potter, Noble; OOPSLA '98 – Clarke; PhD Thesis '01 – Clarke, Drossopoulou; OOPSLA '02 –....
Universes ● Ownership information expressed using annotations – Universe modifiers class C { peer C f1; rep C f2; any C f3; } – Müller, Poetzsch-Heffter; PLFP '99 – Müller '01 – Dietl, Müller; JOT '05 – Cunningham et al; FMCO '08 –....
Universes ● Internal types – lost C – self C
Comparison ● rep C ● peer C ● self C ● any C ● lost C ● C
Existential Quantification ● Jo Ǝ – Cameron, Drossopoulou; ESOP '09 ● Expresses partial knowledge about ownership – Ǝ x.C ● Denotes an object owned by some unknown object
Comparison ● rep C ● peer C ● self C ● any C ● lost C ● C ● Ǝ x.C ● C – Where x is fresh
Comparison - Jo Ǝ - ● Full power of Jo Ǝ not required to model Universes ● We use a smaller calculus - Jo Ǝ -
Comparison - Jo Ǝ - ● In – Owner parameter – this and owner contexts – Existential quantification – Implicit packing and unpacking – subclassing ● Out – Context parameters – Local variables as contexts – Generics – Bounded quantification – Explicit packing and unpacking – Parametric methods
Comparison - Subtyping ● Universe modifier ordering corresponds to existential introduction in subtyping ● eg, – peer C <: any C – C
Comparison – Type Checking ● Viewpoint adaptation used in Universes to adapt modifiers to a different context ● Corresponds to substitution of context parameters, existential unpacking, and some extras
Comparison - Repacking ● Universes can give an expression a lost type ● Jo Ǝ repacks unpacked context parameters
Formalisation of Universes ● An alternative formalisation of Universes ● More closely matches Jo Ǝ – i.e., more closely matches the underlying typing properties
Formalisation of Universes ● lost types are closed to any types – Safe because any C is a supertype of lost C, but can't do anything with lost C ● lost types are only sub- (or super)types of any types ● C – Not even reflexivity ● C – Don't need to check for lost in the type rules
Formalisation of Universes
Formal Properties ● We prove translation from Universes to alternate Universes to Jo Ǝ -
Summary ● Universes and Ownership Types describe the heap structures – We've only examined the descriptive, topological factors ● Universes can be formalised more closely to existing type systems ● A starting point to compare expressivity – Generics
Generics ● Future work ● Add type parameters to Universes and Jo Ǝ - ● Compares GUT ● Expressivity of context parameters mostly given by type parameters: – class List { List next; Object datum; } – class List { List next; X datum; }
Thank you! Questions?