Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith
Background – Ownership Types Multiple Ownership Objects in Boxes MOJO Variance - ? Effects and Disjointness
Background
Ownership Types The heap is messy:
Ownership Types Organise it:
Ownership Types Give each object an owner:
Ownership Types class Project { Task t1; Task t2; List clients; }
Our Work
The Objects In Boxes Model
A Box is a Set of Objects
Objects in Boxes Single owner interpretation: An object is in its owner’s box
But, Programs are not Trees “We’re tired of trees… We should stop believing in trees, roots, radicles” Deleuze and Guattari, A Thousand Plateaus
One Owner is not Enough 75% of ownership structures require multiple ownership [34] Mitchell, ECOOP, ’06 Trees can not describe non-hierarchical structures
We Propose: Objects in Multiple Boxes Multiple Ownership: objects may be in more than one box An object with multiple owners is in the intersection of their boxes:
Objects in Multiple Boxes
MOJO
A Descriptive System Describes the heap Does not restrict references etc.
MOJO Class declarations have the usual, formal ownership parameters: class C …
MOJO Class declarations have the usual, formal ownership parameters: class C … Types may have multiple corresponding actual owner parameters: C
MOJO Class declarations have the usual, formal ownership parameters: class C … Types may have multiple corresponding actual owner parameters: C
MOJO Class declarations have the usual, formal ownership parameters: class C … Types may have multiple corresponding actual owner parameters: C
MOJO class Connection { … } class Client { Connection c; } class Server { Connection c; }
Variance
Variance Connection Some owner
Variance Connection Some box May be the intersection of several boxes Variance in the number of owners
Subtyping Subtyping with wildcards is variant with respect to owners: C
Subtyping Subtyping with wildcards is variant with respect to owners: C
Subtyping Subtyping with wildcards is variant with respect to owners: C
Subtyping Subtyping with wildcards is variant with respect to owners: C But: C
Strict typing – field assignment Strict method sends and assignments to deal with variance of owners: class D { D f; } D da; D d1; D d2; da.f = da;
Strict typing – field assignment Strict method sends and assignments to deal with variance of owners: class D { D f; } D da; D d1; D d2; da.f = da; d1.f = d2;
Strict typing – field assignment Strict method sends and assignments to deal with variance of owners: class D { D f; } D da; D d1; D d2; D db; D dc; d1 = db; d2 = dc; da.f = da; d1.f = d2;
Strict typing – field assignment
Constraints intersects disjoint
Constraints class C a intersects b, b disjoint c { … }
Constraints class D a intersects b { D } class E a disjoint b { }
Constraints class D a intersects b { D } class E a disjoint b { D }
Constraints class D a intersects b { D Object } class E a disjoint b { D }
Effects
Effects
Effects Task t1; Task t2; … t1.f; // reads x / writes ε
Effects Task t1; Task t2; … t1.f; // reads x / writes ε t1.f = t2.f; // reads x,y / writes x
Effects with Multiple Owners Task t1; Task t2; … t1.f; // reads x & ? / writes ε
Effects with Multiple Owners Task t1; Task t2; … t1.f; // reads x & ? / writes ε t1.f = t2.f; // reads x & ?,y & z / writes x & ?
Effects with Multiple Owners t1.f = t2.f; // reads x & ?,y & z/ writes x & ?
Disjointness Two expressions are disjoint if their effects do not overlap Complicated by ? – but & = intersection
Disjointness cl1 disjoint cl2 Connection c1; Connection c2;
Disjointness cl1 disjoint cl2 Connection c1; Connection c2; cl.drop(); //rd cl1 & ? / wr cl1 & ? c2.send(…); //rd cl2 & ? / wr cl2 & ?
Disjointness cl1 disjoint cl2 Connection c1; Connection c2; cl.drop(); //rd cl1 & ? / wr cl1 & ? c2.send(…); //rd cl2 & ? / wr cl2 & ? cl1 & ? # cl2 & ?
Disjointness cl1 disjoint cl2 Connection c1; Connection c2; cl.drop(); //rd cl1 & ? / wr cl1 & ? c2.send(…); //rd cl2 & ? / wr cl2 & ? cl1 & ? # cl2 & ? c2.send() does not affect c1.drop()
Future Work
Future Work Explore variant owners using existential types class TaskList { Task datum; TaskList next; }
Future Work Reference and modification control
Future Work Constraints Topology - inside Unary - may read, may write Binary – may point to, may modify
Summary Multiple Owners Objects in Boxes Variance Formalism - MOJO Effects Disjointness Thank you! Any questions? “structures like the city, which do require overlapping sets within them, are nevertheless persistently conceived as trees” Christopher Alexander, A City is not a Tree