410 likes | 493 Views
Tribal Ownership. Nicholas Cameron James Noble Tobias Wrigstad Victoria University of Wellington Uppsala University. Tribe. world. c1:Canvas. c2:Canvas. s1:Shape. s3:Shape. s2:Shape. s4:Shape. r1:Rectangle. r2:Rectangle. c3:InCanvas. Ownership. world. c1 :Canvas. c2 :Canvas.
E N D
Tribal Ownership Nicholas Cameron James Noble Tobias Wrigstad Victoria University of Wellington Uppsala University
Tribe world c1:Canvas c2:Canvas s1:Shape s3:Shape s2:Shape s4:Shape r1:Rectangle r2:Rectangle c3:InCanvas ...
Ownership world c1:Canvas c2:Canvas s1:Shape s3:Shape s2:Shape s4:Shape r1:Rectangle r2:Rectangle c3:InCanvas ...
Tribal Ownership world c1:Canvas c2:Canvas s1:Shape s3:Shape s2:Shape s4:Shape r1:Rectangle r2:Rectangle c3:InCanvas ...
Virtual Classes • Virtual Classes • Nested Classes • Family Polymorphism • Class Families • Nested Inheritance • ...
Virtual Classes • Scala • Newspeak • GBeta • ...
Tribe class Canvas { class Shape { ... } class Circle extends Shape { ... } class Rectangle extends Shape { ... } ... } class ICanvas extends Canvas { class Shape { void onClick() { ... } } }
Tribe class Canvas { class Shape { ... } class Circle extends Shape { ... } class Rectangle extends Shape { ... } ... } class InCanvas extends Canvas { class Shape { void onClick() { ... } } }
Tribe Canvas Shape Circle Rectangle
Tribe Canvas InCanvas Shape Shape onClick() Circle Circle onClick() Rectangle Rectangle onClick()
Canvas InCanvas Shape Shape onClick() Circle Circle onClick() Rectangle Rectangle onClick()
Tribe world c1:Canvas c2:Canvas s1:Shape s3:Shape s2:Shape s4:Shape r1:Rectangle r2:Rectangle c3:InCanvas ...
Tribe Types c1.Shape c2.Shape
Tribe Types class Canvas { this.Shape f1; world.Canvas f2; class Shape { this.out.out.Canvasf3; this.out.Circle f4; } class Circle extends Shape { ... } }
Tribe Types class Canvas { this.Shape f1; world.Canvas f2; class Shape { ... } } world f2:Canvas f4:Canvas :Canvas f1:Shape :Shape f3:Circle
Tribe Types class Canvas { ... class Shape { this.out.Circle f3; this.out.out.Canvas f4; } } world f2:Canvas f4:Canvas :Canvas f1:Shape :Shape f3:Circle
Ownership Types class List<owner, dOwner> { ListNode<this, dOwner> first; ... } class ListNode<owner, dOwner> { ListNode<owner, dOwner> next; Object<dOwner> datum; ... } new List<this, world>();
world c1:Canvas c2:Canvas s1:Shape s3:Shape r1:Rectangle r2:Rectangle ncameron@ecs.vuw.ac.nz 22
Tribal Ownership c1.Shape
Tribe class Canvas { this.Shape f1; world.Canvas f2; class Shape { this.out.Circle f3; this.out.out.Canvas f4; } class Circle extends Shape { ... } }
Tribal Ownership class Canvas { this.Shape f1; world.Canvas f2; class Shape { this.out.Circle f3; this.out.out.Canvas f4; } class Circle extends Shape { ... } }
What about List? class List<owner, dOwner> { ListNode<this, dOwner> first; ... } class ListNode<owner, dOwner> { ListNode<owner, dOwner> next; Object<dOwner> datum; ... } new List<this, world>();
What about List? - Generics class List<X> { this.ListNode first; class ListNode { this.out.ListNode next; Xdatum; ... } ... } new this.List<world.Object>();
What about List? - Generics class List<X> { this.ListNode first; class ListNode { this.out.ListNode next; X datum; ... } ... } new this.List<world.Object>();
What about List? class List<X> { this.ListNode first; class ListNode { this.out.ListNode next; X datum; ... } ... } new this.List<world.Object>();
What about List? – Module classes module Collections { class List<X> { ... } } class Foo imports world.Collections { this.List<world.Object> f; }
Encapsulation Owners-as-Dominators Owners-as-Modifiers
Encapsulation Owners-as-Local-Dominators
O-as-LD public private Only public classes can be named externally
Summary • Virtual classes in Tribe give ownership • No syntactic overhead • Generics • Module classes • Cross family inheritance • Owners-as-Local-Dominators