Download presentation
Presentation is loading. Please wait.
Published byWilliam Webb Modified over 9 years ago
1
Existential Quantification for Variant Ownership Nicholas Cameron Sophia Drossopoulou Imperial College London (Victoria University of Wellington) ncameron@ecs.vuw.ac.nz
2
Ownership
3
Statically partitions the heap Organises objects into an hierarchical structure Improves reasoning about programs Effects Concurrency Memory Management Garbage Collection Many flavours Encapsulation properties
4
Ownership
6
Parametric ownership Each object is owned by a context context object owner Classes and types are parameterised by contexts
7
Ownership Classes are parameterised by formal contexts class C {...} o1 is the owner of objects of class C o2 is another context
8
Ownership Types are parameterised by actual contexts class C {...} C this C World, formal contexts C Final variables, final fields
9
Ownership Ownership hierarchy o1:C o2:C o1 is inside o3 o2 is inside o4 If o4 is inside o3 then o2 is inside o3
10
Existential Types
11
Used to model abstraction Ǝ X.(X → int) Or variance in generic object-oriented languages Ǝ X.List List (Java wildcards)
12
Existential Types Bounds Ǝ X→[Merino Animal].List Merino <: X <: Animal
13
Existential Types Safe covariance: Ǝ X→[ Sheep].List List
14
Existential Types Packing pack( List ) = Ǝ X.List A is hidden – it is the witness type close expression
15
Existential Types Unpacking unpack( Ǝ X.List ) = List Z is a fresh type variable open expression
16
Jo Ǝ - Motivation
17
Motivation Desire for variance +, -, * in Variant Ownership Types Lu, Potter, ECOOP '06 ? in MOJO Cameron, Drossopoulou, Noble, Smith, OOPSLA '07 any / readonly in Universes Müller, Dietl, et al., many papers any in Effective Ownership Lu, Potter, POPL '06 ...
18
Motivation All tailor-made solutions No connection to established type theory Limited expressivity
19
Motivation E.g., ? in MOJO Strict substitution If ? In.... Strict method and field lookup Permeates entire calculus Additional subtype rules
20
Motivation
21
Jo Ǝ
22
Goals: Expressivity Uniformity
23
Jo Ǝ Existential quantification of contexts Parametrisation by types and contexts This combination gives improved expressivity
24
Jo Ǝ Class List { List next; X datum; X get() {...} void add(X x) {...} } context parameters type parameters
25
Jo Ǝ Generics and quantification for expressivity: List > Ǝ o.List > List > Ǝ o.List >
26
Jo Ǝ Flexible ownership language Parametric methods Type and context parameters Actual contexts Explicit unpacking Upper and lower bounds on formal contexts
27
Jo Ǝ Upper and lower bounds on formal contexts Ǝ o→[o5 o2].Sheep o is inside o2 o5 is inside o
28
Jo Ǝ Uniform Uses only the purest form of existential types No special cases to support variance No tailored annotations Variance is dealt with locally Direct relation to long history of research on existential types
29
Jo Ǝ Describes the topology of the heap This topology is fixed, not variant Type sound Static description of topology reflects heap at runtime Ownership hierarchy can 'grow', but not 'mutate' Useful e.g. effects
30
Jo Ǝ Can encode other systems Generic Universes Dietl, Drossoploulou, Müller, ECOOP '07 Existential owners for downcasting Wrigstad, Clarke, JOT, May '07 Variant Ownership Types? Lu, Potter, ECOOP '06 Single owner case of MOJO Cameron, Drossopoulou, Noble, Smith, OOPSLA '07
31
How it Works
32
Jo Ǝ
33
Three environments Variable environment
34
Jo Ǝ Owner environment Quantified contexts are unpacked here Does not affect this rule
35
Jo Ǝ Type environment Owner bounds
36
Jo Ǝ Substitute receiver for this
37
Jo Ǝ Receiver cannot be arbitrary expression But no loss of expressivity Thanks to open expression
38
Jo Ǝ Receiver must have class type Forces unpacking Don't account for quantification here
39
Summary Parametric ownership + Existential quantification of contexts + Generics = Jo Ǝ Expressive and Uniform Can encode existing systems
40
Thank you! ncameron@ecs.vuw.ac.nz
41
Ownership Encapsulation Owners-as-Dominators Owners-as-Modifiers Link Soundness ... Owners-as-Dominators All paths through the heap to an object are dominated by that object's owner Common for parametric ownership systems Useful for garbage collection, memory management,...
42
Ownership Owners-as-Dominators
43
Ownership Owners-as-Modifiers
44
Encapsulation
45
Jo Ǝ deep Owners-as-Dominators Strong encapsulation property Very small modifications Well-formed heap Well-formed classes Class type checking
46
Jo Ǝ deep Treat existentially quantified context variables as their lower bounds Owners-as-dominators involves showing referenced objects are outside their owners If the lower bound is outside, then the hidden context must be outside
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.