ABSTRACT
Chaperones and impersonators provide run-time support for interposing on primitive operations such as function calls, array access and update, and structure field access and update. Unlike most interposition support, chaperones and impersonators are restricted so that they constrain the behavior of the interposing code to reasonable interposition, which in practice preserves the abstraction mechanisms and reasoning that programmers and compiler analyses rely on.
Chaperones and impersonators are particularly useful for implementing contracts, and our implementation in Racket allows us to improve both the expressiveness and the performance of Racket's contract system. Specifically, contracts on mutable data can be enforced without changing the API to that data; contracts on large data structures can be checked lazily on only the accessed parts of the structure; contracts on objects and classes can be implemented with lower overhead; and contract wrappers can preserve object equality where appropriate. With this extension, gradual typing systems, such as Typed Racket, that rely on contracts for interoperation with untyped code can now pass mutable values safely between typed and untyped modules.
Supplemental Material
Available for Download
This contains the technical appendices from the paper. See the included index.html file for more information.
- Jonathan Aldrich. Open Modules: Modular Reasoning About Ad-vice. In Proc. European Conf. Object-Oriented Programming, 2005. Google ScholarDigital Library
- Thomas H. Austin, Tim Disney, and Cormac Flanagan. Virtual Values for Language Extension. In Proc. ACM Conf. Object-Oriented Programming, Systems, Languages and Applications, 2011. Google ScholarDigital Library
- Stephanie Balzer, Patrick Eugster, and Bertrand Meyer. Can Aspects Implement Contracts? In Proc. Rapid Implemetation of Software Engineering Techniques, pp. 145--157, 2005. Google ScholarDigital Library
- Olaf Chitil. Practical Typed Lazy Contracts. In Proc. ACM Intl. Conf. Functional Programming, 2012. Google ScholarDigital Library
- Olaf Chitil and Frank Huch. A pattern logic for prompt lazy asser-tions. In Proc. Intl. Sym. Functional and Logic Programming, pp. 126--144, 2006. Google ScholarDigital Library
- Olaf Chitil, Dan McNeill, and Colin Runciman. Lazy Assertions. In Proc. Intl. Sym. Functional and Logic Programming, 2003.Google Scholar
- Curtis Clifton and Gary T. Leavens. Observers and assistants: A proposal for modular aspect-oriented reasoning. In Proc. Foundations of Aspect-Oriented Languages, 2002.Google Scholar
- Daniel S. Dantas and David Walker. Harmless Advice. In Proc. ACM Sym. Principles of Programming Languages, 2006. Google ScholarDigital Library
- Jessie Dedecker, Tom Van Cutsem, Stijn Mostinckx, Theo D'Hondt, and Wolfgang De Meuter. Ambient-Oriented Programming. In Proc. ACM Conf. Object-Oriented Programming, Systems, Languages and Applications, pp. 31--40, 2005. Google ScholarDigital Library
- Digital Mars. D Programming Language. 1999. http://www.digitalmars.com/d/Google Scholar
- Tim Disney. Contracts.coffee. 2012. http://disnetdev.com/contracts.coffee/Google Scholar
- James E. Donnelley. A distributed capability computing system. In Proc. Intl. Conf. on Computer Communication, 1976.Google ScholarDigital Library
- Pedro Felzenszwalb and David McAllester. A min-cover approach for finding salient curves. In Proc. IEEE Wksp. Perceptual Organization in Computer Vision, 2006. Google ScholarDigital Library
- Robert Bruce Findler andMatthias Felleisen. Contracts for Higher-Order Functions. In Proc. ACM Intl. Conf. Functional Programming, pp. 48--59, 2002. Google ScholarDigital Library
- Robert Bruce Findler, Shu-yu Guo, and Anne Rogers. Lazy Contract Checking for Immutable Data Structures. In Proc. Implementation and Application of Functional Languages, 2007.Google Scholar
- Matthew Flatt and PLT. Reference: Racket. PLT Inc., PLT-TR-2010-1, 2010. http://racket-lang.org/tr1/Google Scholar
- Brian Hackett and Shu-Yu Guo. Fast and precise type inference for JavaScript. In Proc. Conf. on Programming Language Design and Implementation, 2012. Google ScholarDigital Library
- Ralf Hinze, Johan Jeuring, and Andres Löh. Typed Contracts for Functional Programming. In Proc. Sym. Functional and Logic Programming, pp. 208--225, 2006. Google ScholarDigital Library
- Gregor Kiczales, John Lamping, Anurag Mendhekar, Chris Maeda, Cristina Lopes, Jean-Marc Loingtier, and John Irwin. Aspect-Oriented Programming. In Proc. European Conf. Object-Oriented Programming, pp. 220--242, 1997.Google Scholar
- Gregor J. Kiczales, James des Rivieres, and Daniel G. Bobrow. The Art of the Metaobject Protocol. MIT Press, 1991. Google ScholarDigital Library
- B. W. Lampson, J. J. Horning, R. L. London, J. G. Mitchell, and G. J. Popek. Report on the programming language Euclid. ACM SIGPLAN Notices 12(2), pp. 1--79, 1977. Google ScholarDigital Library
- D. C. Luckham and F. W. von Henke. An overview of Anna, a specification language for Ada. IEEE Software 2(2), pp. 9--22, 1985. Google ScholarDigital Library
- Jacob Matthews and Amal Ahmed. Parametric Polymorphism Through Run-Time Sealing, or, Theorems for Low, Low Prices! In Proc. European Sym. on Programming, 2008. Google ScholarDigital Library
- E. Mera, P. Lopez-Garcia, and M. Hermenegildo. Integrating Software Testing and Run-Time Checking in an Assertion Verification Framework. In Proc. Intl. Conf. on Logic Programming, LNCS 5649, 2009. Google ScholarDigital Library
- Bertrand Meyer. Eiffel : The Language. Prentice Hall PTR, 1991. Google ScholarDigital Library
- Mark S. Miller. Robust Composition: Towards a Unified Approach to Access Control and Concurrency Control. PhD dissertation, John Hopkins University, 2006. Google ScholarDigital Library
- Stijn Mostinckx, Tom Van Cutsem, Elisa Gonzalez Boix, Stijn Timbermont, Éric Tanter, and Wolfgang De Meuter. Mirror-based reflection in AmbientTalk. Software-Practice and Experience 39, pp. 661--699, 2009. Google ScholarDigital Library
- Toby Murray. Analysing the Security Properties of Object-Capability Patterns. PhD dissertation, Hertford College, Oxford University, 2010.Google Scholar
- Bruno C. d. S. Oliveira, Tom Schrijvers, and William R. Cook. Effective Advice: Disciplined Advice with Explicit Effects. In Proc. Aspect-Oriented Software Development, 2010. Google ScholarDigital Library
- Oracle. java.lang.reflect.Proxy. 2000. http://download.oracle.com/javase/6/docs/api/java/lang/reflect/Proxy.htmlGoogle Scholar
- Susan A. Rajunas. The KeyKOS/KeySAFE system design. Key Logic, Inc, SEC009-01, 1989. http://www.cis.upenn.edu/~KeyKOSGoogle Scholar
- Martin Rinard, Alexandru Salcianu, and Suhabe Bugrara. A Classification System and Analysis for Aspect-Oriented Programs. In Proc. Intl. Sym. on the Foundations of Software Engineering, 2004. Google ScholarDigital Library
- T. Stephen Strickland and Matthias Felleisen. Contracts for First-Class Classes. In Proc. Dynamic Languages Symposium, pp. 97--112, 2010. Google ScholarDigital Library
- Sam Tobin-Hochstadt and Matthias Felleisen. The Design and Implementation of Typed Scheme. In Proc. ACM Sym. Principles of Programming Languages, pp. 395--406, 2008. Google ScholarDigital Library
- Tom Van Cutsem and Mark Miller. Proxies: Design Principles for Robust Object-oriented Intercession APIs. In Proc. Dynamic Languages Symposium, pp. 59--72, 2010. Google ScholarDigital Library
- Tom Van Cutsem and Mark Miller. On the design of the ECMAScript Reflection API. Vrije Universiteit Brussel, VUB-SOFT-TR-12-03, 2012.Google Scholar
Index Terms
- Chaperones and impersonators: run-time support for reasonable interposition
Recommendations
Collapsible contracts: fixing a pathology of gradual typing
The promise of gradual typing is that programmers should get the best of both worlds: the static guarantees of static types, and the dynamic flexibility of untyped programming. This is an enticing benefit, but one that, in practice, may carry significant ...
Chaperones and impersonators: run-time support for reasonable interposition
OOPSLA '12Chaperones and impersonators provide run-time support for interposing on primitive operations such as function calls, array access and update, and structure field access and update. Unlike most interposition support, chaperones and impersonators are ...
Relationally-parametric polymorphic contracts
DLS '07: Proceedings of the 2007 symposium on Dynamic languagesThe analogy between types and contracts raises the question of how many features of static type systems can be expressed as dynamic contracts. An important feature missing in prior work on contracts is parametricity, as represented by the polymorphic ...
Comments