Linearity for Objects - PowerPoint PPT Presentation

1 / 12
About This Presentation
Title:

Linearity for Objects

Description:

Enforce no copies are made of certain program values. Well ... Andi Bejleri, Jonathan Aldrich, and Kevin Bierhoff. Ego: Controlling the Power of Simplicity. ... – PowerPoint PPT presentation

Number of Views:48
Avg rating:3.0/5.0
Slides: 13
Provided by: mke71
Category:

less

Transcript and Presenter's Notes

Title: Linearity for Objects


1
Linearity for Objects
  • Matthew Kehrt
  • Advisor Jonathan Aldrich

2
Linearity
  • Linear Type Systems
  • Enforce no copies are made of certain program
    values
  • Well understood in functional languages
  • Less understood in other settings

3
Ego
  • Object calculus based on the Self language
  • Prototype based
  • Allows changes to an objects interface
  • Addition and removal of methods
  • Changing delegation
  • Used to model objects that change
  • Sockets
  • Type system to prevent runtime errors
  • Uses linear types

4
Ego Type System
  • Linear objects
  • Pointers are tracked by the type system
  • Enforces only one reference to the object
  • No aliases
  • Used to enforce type safety
  • Ego allows interface changes only to linear
    objects
  • Linear methods
  • Called only once
  • Can mention linear objects

5
Relaxing Linearity
  • Linear references to objects are unwieldy
  • Want to make multiple copies and later change an
    objects interface
  • Similar to reader/writer problem
  • Reading from and then closing sockets

6
Borrowing
  • We borrow linear objects to make temporary
    aliases
  • Borrowed objects may be aliased
  • No changes may be made to borrowed objects
    interfaces

7
Borrowing
  • An objects is borrowed within a given expression
  • Within this expression, the original, linear
    pointer is unavailable
  • This prevents the objects interface from being
    changed while the object is borrowed
  • No borrowed pointers are allowed to escape this
    expression
  • This maintains linearity when the objects
    interface can be changed

8
Regions
  • Types of borrowed objects are annotated with
    regions
  • Unique token per borrowing
  • Indicates where the borrowed location is usable
  • Used to guarantee no alias escapes

9
Regions
  • We keep track of what regions are annotating
    borrowed locations in a given expression
  • Escaped aliases have regions not in scope
  • This is a type error
  • We allow borrowed pointers to be stored in
    objects that persist beyond the expression in
    which they are borrowed
  • But their use is a type error

10
let!
  • We borrow objects with the let! construct
  • let!(r) x e1
  • in y e2
  • in e3

11
What Weve Done
  • Cleaned up Ego
  • Formal definition of Ego with let!
  • Dynamic semantics
  • Type system
  • Proof of type safety

12
References
  • M. Abadi, L.Cardelli. A theory of objects.
    Springer, 1996.
  • Andi Bejleri, Jonathan Aldrich, and Kevin
    Bierhoff. Ego Controlling the Power of
    Simplicity. Submitted for publication.
  • K. Fisher and J. C. Mitchell. A Delegation-based
    Object Calculus with Subtyping. In Proc.
    Fundamentals of Computation Theory, 1995.
  • D. Ungar, R. B. Smith. Self The power of
    simplicity. Proc. Object-Oriented Programming
    Systems, Languages and Applications
  • P. Wadler. Linear types can change the world!
    In M. Broy and C. Jones, editors, Programming
    Concepts and Methods, North Holland, 1990
Write a Comment
User Comments (0)
About PowerShow.com