environmental acquisition revisited
play

Environmental Acquisition Revisited Richard Cobbe and Matthias - PowerPoint PPT Presentation

Environmental Acquisition Revisited Richard Cobbe and Matthias Felleisen Northeastern University Environmental Acquisition Revisited POPL 2005 p.1/30 What is Acquisition? Environmental Acquisition Revisited POPL 2005 p.2/30


  1. Environmental Acquisition Revisited Richard Cobbe and Matthias Felleisen Northeastern University Environmental Acquisition Revisited — POPL 2005 – p.1/30

  2. What is Acquisition? Environmental Acquisition Revisited — POPL 2005 – p.2/30

  3. Example: Swing Containers JDialog JRootPane JPanel JPanel JPanel JButton located only at top level � ✁ ☎ ✄ ✂ ✂ ✆ ✝ ✞ must chase pointers to access root pane � ✟ ✄ ✄ ✠ ✂ ✝ Environmental Acquisition Revisited — POPL 2005 – p.3/30

  4. Example: Financial Application Fund Account TaxInfo taxPolicy Fund funds MutualFund FundGroup int fundID Fund funds int balance TaxInfo taxPolicy TaxInfo getTaxPolicy() { ... } Operations on s must know tax policy � ✄ ✁ ✂ Environmental Acquisition Revisited — POPL 2005 – p.4/30

  5. Example: Financial Application Fund Account TaxInfo taxPolicy contains Fund funds MutualFund FundGroup int fundID contains Fund funds int balance TaxInfo taxPolicy acquires TaxInfo taxPolicy Operations on s must know tax policy � ✄ ✁ ✂ With acquisition, no longer need to maintain and chase parent refs Environmental Acquisition Revisited — POPL 2005 – p.4/30

  6. Example: IDE Wizard Dialog HorizontalPanel ... ClassUnionWizard errorMessage( ) produce( ) VariantPanel add( ) produce( ) UnionInfo errorMessage( ) vPanel Environmental Acquisition Revisited — POPL 2005 – p.5/30

  7. Example: Wizard with Acquisition Dialog HorizontalPanel ... ClassUnionWizard errorMessage( ) produce( ) VariantPanel add( ) produce( ) UnionInfo acquires errorMessage( ) vPanel Environmental Acquisition Revisited — POPL 2005 – p.6/30

  8. Containment Invariants Invariants ensured by language support for acquisition: Environmental Acquisition Revisited — POPL 2005 – p.7/30

  9. Containment Invariants Invariants ensured by language support for acquisition: Objects allow access to their containers � Environmental Acquisition Revisited — POPL 2005 – p.7/30

  10. Containment Invariants Invariants ensured by language support for acquisition: Objects allow access to their containers � Two-way links (or their analog) are consistent � Environmental Acquisition Revisited — POPL 2005 – p.7/30

  11. Restrictions on Acquisition Limit object’s “environment” to its containers � Only specifically marked fields establish containment � relationship An object may have at most one container � Object containment cycles forbidden � Environmental Acquisition Revisited — POPL 2005 – p.8/30

  12. Jacques : the Formal Model Environmental Acquisition Revisited — POPL 2005 – p.9/30

  13. Jacques Based on ClassicJava , formal model of Java by Flatt, Krishnamurthi, and Felleisen (1998). Supported features: core OO: classes, inheritance, method dispatch � field assignment � Environmental Acquisition Revisited — POPL 2005 – p.10/30

  14. Jacques Based on ClassicJava , formal model of Java by Flatt, Krishnamurthi, and Felleisen (1998). Supported features: core OO: classes, inheritance, method dispatch � field assignment � field and method acquisition � explicit marks for “containment” fields � list of possible containers in class definitions � Environmental Acquisition Revisited — POPL 2005 – p.10/30

  15. Environmental Acquisition Revisited — POPL 2005 – p.11/30 ✌ ✌ ✁ ✞ ✒ ✟ ✝ ✆ ☞ ✑ ✆ ☎ ✑ ☛ ✁ ✑ ✆ ☎ ✡ ✌ ✄ ✝ ✝ ✂ ✂ ✕ ✘ ☎ ☛ ✝ ☎ ✂ ✄ ✚ ☞ ✂ ✂ ✒ ✘ ✓ ✂ ✆ ✝ ✑ ✁ ✂ ☎ ✑ Wizard Example ✟ ☞ ✠ ✒ ✑ ✝ ✄ ✏ ✙ ✂ ✁ ✞ ✌ ✑ ✟ ✞ ✄ ✔ ✏ ✑ ✝ ✝ ✞ ✝ ✞ ✕ ✑ ✆ ✘ ✞ ✞ ✂ ✑ ✆ ☎ ✄ ✄ ✌ ✑ ✞ ✎ ✁ ✂ ✄ ✑ ✠ ✞ ✞ ✂ ✔ ✕ ✝ ✟ ✁ ✞ ✞ ✑ ✆ ✞ ✗ ✂ ✄ � ✑ ✝ ✠ ☎ ☞ ✝ ☎ ✑ ✝ ✆ ✟ ✟ ✄ ✂ ✔ ✝ ✟ ☞ ✆ ☎ ✞ ✂ ✆ ✝ ✟ ☞ ☞ ✄ ✝ ✝ ✆ ✂ ✖ ✞ ☎ ✆ ☞ ✂ ☎ ✝ ✆ ✟ ✟ ✟ ☎ ✄ ✄ ☞ ✍ ✄ ☎ ☎ ☎ ✑ ✆ ✠ ✂ ✂ ✂ ✑ ✍ ✎ ✎ ✎ ✂ ✂ ✟ ✑ ✂ ✂ ✆ ✆ ✁ ✁ � ✒ � ✒

  16. Environmental Acquisition Revisited — POPL 2005 – p.12/30 ✏ ✌ ✁ ✕ Jacques : Wizard Example ✘ ✞ ✟ ✝ ✂ ✆ ✚ ☞ ✆ ☎ ✘ ☛ ✁ ✆ ✝ ☎ ✌ ✡ ✄ ☎ ✝ ✝ ✟ ☞ ☞ ✂ ✂ ✄ ✏ ✆ ✙ ☎ ✁ ☛ ✝ ☛ ✞ ☎ ✔ ✄ ✝ ☞ ✞ ☎ ✆ ✡ ✘ ✂ ✂ ✒ ✆ ✓ ✝ ✂ ☎ ✆ ✎ ✂ ✂ ✑ ✁ ✂ ✂ ☎ ✑ ✟ ✝ ✠ ✁ ✒ ✞ ✑ ✝ ✄ ✗ ✞ ✝ ☞ ✂ ✞ ✂ ✌ ✑ ✟ ✆ ✂ ✄ ✂ ✏ ✑ ✝ ✞ ✆ ✝ ☎ ☞ ✕ ✑ ☞ ✞ ✄ ✞ ✁ ✂ ✑ ✝ ✠ ✄ ✄ ✌ ✞ ✑ ✆ ✞ ✁ ✄ ✑ ✟ ✠ ✟ ✞ ✞ ☎ ✔ ✕ ☞ ✝ ✟ ✞ ✞ ☎ ✑ ✆ ✆ ✝ ✂ ✄ � ✂ ✑ ✍ ✠ ☎ ✎ ✝ ☎ ☎ ✑ ✝ ✆ ✟ ✟ ✄ ✔ ✝ ✟ ✆ ✂ ✄ ✞ ✂ ✂ ✆ ✝ ✝ ✝ ✟ ☞ ✞ ✝ ✆ ✂ ✂ ✖ ☞ ☎ ☎ ✆ ☞ � ✂ ☎ ☎ ✝ ✆ ✟ ✟ ✠ ✄ ✄ ✄ � ✝ ✍ ✄ ☎ ☎ ✑ ✠ ✂ ✂ ✂ � ✑ ✎ ✎ ✆ ✂ � ✂ ✟ ✑ ✂ ✂ ✆ ✆ ✁ ✁ � ✒ � ✒

  17. Static Check I A B : contained A C : contained B D : contained C bool fd int fd contains D d acquires int fd contains B b contains C c Environmental Acquisition Revisited — POPL 2005 – p.13/30

  18. Static Check I A B : contained A C : contained B D : contained C bool fd int fd contains D d acquires int fd contains B b contains C c acquires from , and types match. � ✝ ✟ ✟ Program is well-typed. Environmental Acquisition Revisited — POPL 2005 – p.13/30

  19. Static Check II A B : contained A C : contained B D : contained C bool fd int fd bool fd acquires int fd contains B b contains C c contains D d Environmental Acquisition Revisited — POPL 2005 – p.14/30

  20. Static Check II A B : contained A C : contained B D : contained C bool fd int fd bool fd acquires int fd contains B b contains C c contains D d acquires from , and types are not compatible. ✠ � ✝ ✟ Program is not well-typed. Environmental Acquisition Revisited — POPL 2005 – p.14/30

  21. Design Decisions Environmental Acquisition Revisited — POPL 2005 – p.15/30

  22. Running Example Ctnr1 Ctnr2 Prop1 fd Prop2 fd contains Item it contains Item it Prop1 meth(Property p) { ... } Property meth(Prop2 x) { ... } Property Item : contained Ctnr1, Ctnr2 ... acquires Property fd acquires Property meth(Prop2) Prop1 Prop2 ... ... Environmental Acquisition Revisited — POPL 2005 – p.16/30

  23. Acquisition by Value and by Name aCtnr1 : Ctnr1 anItem : Item aCtnr2 : Ctnr2 contains Item it acquires Property fd contains Item it Prop1 fd Prop2 fd When does acquire ’s value? ✆ ✝ ✟ ✄ ✆ ✞ ✝ ✚ Environmental Acquisition Revisited — POPL 2005 – p.17/30

  24. Acquisition by Value and by Name aCtnr1 : Ctnr1 anItem : Item aCtnr2 : Ctnr2 contains Item it acquires Property fd contains Item it Prop1 fd Prop2 fd When does acquire ’s value? ✆ ✝ ✟ ✄ ✆ ✞ ✝ ✚ By value: when is placed into . ✠ � ✆ ✄ ✄ � ✆ ✝ ✞ ✚ ✆ ✝ ☞ Environmental Acquisition Revisited — POPL 2005 – p.17/30

  25. Acquisition by Value and by Name aCtnr1 : Ctnr1 anItem : Item aCtnr2 : Ctnr2 contains Item it acquires Property fd contains Item it Prop1 fd Prop2 fd When does acquire ’s value? ✆ ✝ ✟ ✄ ✆ ✞ ✝ ✚ By value: when is placed into . ✠ � ✆ ✄ ✄ � ✆ ✝ ✞ ✚ ✆ ✝ ☞ By name: when is referenced. ✆ ✝ ✟ ✄ � ✆ ✝ ✞ ✚ ✑ Environmental Acquisition Revisited — POPL 2005 – p.17/30

  26. Acquisition by Value and by Name aCtnr1 : Ctnr1 anItem : Item aCtnr2 : Ctnr2 contains Item it acquires Property fd contains Item it Prop1 fd Prop2 fd When does acquire ’s value? ✆ ✝ ✟ ✄ ✆ ✞ ✝ ✚ By value: when is placed into . ✠ � ✆ ✄ ✄ � ✆ ✝ ✞ ✚ ✆ ✝ ☞ By name: when is referenced. ✆ ✝ ✟ ✄ � ✆ ✝ ✞ ✚ ✑ Both are sound; primarily affects visibility of assignments. Environmental Acquisition Revisited — POPL 2005 – p.17/30

  27. Acquisition by Value and by Name aCtnr1 : Ctnr1 anItem : Item aCtnr2 : Ctnr2 contains Item it acquires Property fd contains Item it Prop1 fd Prop2 fd Two questions with acquisition-by-value: Environmental Acquisition Revisited — POPL 2005 – p.18/30

  28. Acquisition by Value and by Name aCtnr1 : Ctnr1 anItem : Item aCtnr2 : Ctnr2 contains Item it acquires Property fd contains Item it Prop1 fd Prop2 fd Two questions with acquisition-by-value: null ; 1. ✠ � ☎ ✄ ✄ ✆ ✝ ☞ : � ✑ : previous value or undefined? ✆ ✝ ✟ ✄ ✆ ✝ ✞ ✚ ✑ Environmental Acquisition Revisited — POPL 2005 – p.18/30

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend