skip to main content
research-article

Beyond static and dynamic scope

Published:26 October 2009Publication History
Skip Abstract Section

Abstract

Traditional treatment of scoping in programming languages considers two opposite semantics: static scoping, where the scope of a binding is a block of program text, and dynamic scoping, where a binding is in effect during the whole reduction of an expression to a value. Static scoping and dynamic scoping are however but two points in the design space of scoping mechanisms. As a result, most proposed language mechanisms that rely on some notion of scoping, such as variable bindings of course, but also more exotic ones like aspects and mixin layers, adopt either one or the other semantics. As it turns out, these two semantics are sometimes too extreme, and a mixture of both is needed. To achieve this, language designers and/or programmers have to resort to ad hoc solutions. We present a general scoping model that simply expresses static and dynamic scoping, and that goes further by allowing fine-grained exploration of the design space of scoping. The model, called scoping strategies, gives precise control over propagation and activation of language mechanisms. While we have already studied it for aspects, we hereby show that the model is not restricted to aspects, by treating in depth its application to the most standard kind of adaptation: variable bindings. We also briefly discuss its application to mixin layers, and program monitoring. We believe that research in programming language constructs can benefit from a more flexible notion of scoping that goes beyond the static/dynamic dichotomy.

References

  1. Martin Abadi, Luca Cardelli, Pierre-Louis Curien, and Jean-Jacques Lévy. Explicit substitutions. Journal of Functional Programming, 1(4):375--416, 1992.Google ScholarGoogle ScholarCross RefCross Ref
  2. Ivica Aracic, Vaidas Gasiunas, Mira Mezini, and Klaus Ostermann. An overview of CaesarJ. In Transactions on Aspect-Oriented Software Development, volume 3880 of Lecture Notes in Computer Science, pages 135--173. Springer-Verlag, February 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Alexandre Bergel, Stéphane Ducasse, and Roel Wuyts. Classboxes: A minimal module model supporting local rebinding. In Proceedings of the Joint Modular Languages Conference (JMLC'03), volume 2789 of Lecture Notes in Computer Science, pages 122--131. Springer-Verlag, 2003.Google ScholarGoogle ScholarCross RefCross Ref
  4. Dave Clarke, Pascal Costanza, and Éric Tanter. How should context-escaping closures proceed? In Workshop on Context-Oriented Programming, Genova, Italy, July 2009. To appear. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Pascal Costanza and Robert Hirschfeld. Language constructs for context-oriented programming - an overview of ContextL. In ACM Dynamic Language Symposium (DLS 2005), San Diego, CA, USA, October 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Mariangiola Dezani-Ciancaglini, Paola Giannini, and Oscar Nierstrasz. A calculus of evolving objects. Scientific Annals of Computer Science, 18:63--98, 2008.Google ScholarGoogle Scholar
  7. Christopher Dutchyn, David B. Tucker, and Shriram Krishnamurthi. Semantics and scoping of aspects in higher-order languages. Science of Computer Programming, 63(3):207--239, December 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Matthias Felleisen. The theory and practice of first-class prompts. In Proceedings of the ACM Symposium on Principles of Programming Languages (POPL'88), pages 180--190. ACM Press, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Matthias Felleisen. On the expressive power of programming languages. Science of Computer Programming, 17:35--75, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Matthew Flatt, Gang Yu, Robert Bruce Findler, and Matthias Felleisen. Adding delimited and composable control to a production programming environment. In Proceedings of the 12th ACM SIGPLAN Conference on Functional Programming (ICFP 2007), pages 165--176, Freiburg, Germany, October 2007. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Daniel P. Friedman and Mitchell Wand. Reification: Reflection without metaphysics. In Proceedings of the Annual ACM Symposium on Lisp and Functional Programming, pages 348--355, August 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. James Gosling, Bill Joy, Guy Steele, and Gilad Bracha. The Java Language Specification, 3rd edition. Addison-Wesley, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. G. Kiczales, J. Irwin, J. Lamping, J. Loingtier, C. V. Lopes, C. Maeda, and A. Mendhekar. Aspect oriented programming. In Special Issues in Object-Oriented Programming. Max Muehlhaeuser (general editor) et al., 1996.Google ScholarGoogle Scholar
  14. Gregor Kiczales, Erik Hilsdale, Jim Hugunin, Mik Kersten, Jeffrey Palm, and William Griswold. An overview of AspectJ. In Jorgen L. Knudsen, editor, Proceedings of the 15th European Conference on Object-Oriented Programming (ECOOP 2001), number 2072 in Lecture Notes in Computer Science, pages 327--353, Budapest, Hungary, June 2001. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Gregor Kiczales, John Lamping, Anurag Mendhekar, Chris Maeda, Cristina V. Lopes, Jean-Marc Loingtier, and John Irwin. Aspect-oriented programming. In Mehmet Akşit and Satoshi Matsuoka, editors, Proceedings of the 11th European Conference on Object-Oriented Programming (ECOOP 97), volume 1241 of Lecture Notes in Computer Science, pages 220--242, Jyväskylä, Finland, June 1997. Springer-Verlag.Google ScholarGoogle Scholar
  16. Oleg Kiselyov, Chung chieh Shan, and Amr Sabry. Delimited dynamic binding. In Proceedings of the 11th ACM SIGPLAN Conference on Functional Programming (ICFP 2006), pages 26--37, Portland, Oregon, USA, September 2006. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Hidehiko Masuhara, Gregor Kiczales, and Christopher Dutchyn. A compilation and optimization model for aspect-oriented programs. In G. Hedin, editor, Proceedings of Compiler Construction (CC2003), volume 2622 of Lecture Notes in Computer Science, pages 46--60. Springer-Verlag, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Luc Moreau. A syntactic theory of dynamic binding. Higher-Order and Sympolic Computation, 11(3):233--279, 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Guillaume Pothier and Éric Tanter. Back to the future: Omniscient debugging. IEEE Software, 2009. To appear. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Guillaume Pothier, Éric Tanter, and José Piquer. Scalable omniscient debugging. In Proceedings of the 22nd ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages and Applications (OOPSLA 2007), pages 535--552, Montreal, Canada, October 2007. ACM Press. ACM SIGPLAN Notices, 42(10). Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Brian C. Smith. Reflection and semantics in Lisp. In Proceedings of the 14th Annual ACM Symposium on Principles of Programming Languages (POPL), pages 23--35, January 1984. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Éric Tanter. Expressive scoping of dynamically-deployed aspects. In Proceedings of the 7th ACM International Conference on Aspect-Oriented Software Development (AOSD 2008), pages 168--179, Brussels, Belgium, April 2008. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Éric Tanter, Johan Fabry, Rémi Douence, Jacques Noyé, and Mario Südholt. Expressive scoping of distributed aspects. In Proceedings of the 8th ACM International Conference on Aspect-Oriented Software Development (AOSD 2009), pages 27--38, Charlottesville, Virginia, USA, March 2009. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Mitchell Wand, Gregor Kiczales, and Christopher Dutchyn. A semantics for advice and dynamic join points in aspect-oriented programming. ACM Transactions on Programming Languages and Systems, 26(5):890--910, September 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Alessandro Warth, Milan Stanojević, and Todd Millstein. Statically scoped object adaptation with expanders. In Proceedings of the 21st ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages and Applications (OOPSLA 2006), pages 37--55, Portland, Oregon, USA, October 2006. ACM Press. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Beyond static and dynamic scope

        Recommendations

        Reviews

        Scott Arthur Moody

        Not since call-by-name-Algol's unattended lexical construct that came with powerful consequences-have the dimensions between static and dynamic scoping strategies been discussed so nicely. Tanter introduces a new model that he uses to describe a wide range of operational language-scoping semantics. He also introduces a formal language to support descriptions and associated proofs. He thinks these could be extended to related areas such as context-oriented programming, aspect-oriented programming, and program monitoring. Various scoping dimensions are expressed throughout the paper, starting with static and dynamic strategies. Tanter then introduces other scoping. For example, a pervasive binding is a binding that is in effect during the whole extent of the reduction of the expression on which it is deployed, such as dynamic binding. In addition, the values created live on pervasively after the procedure is completed. Flat binding is a binding that is available only in the lexical region, where it is deployed but not captured in lexical closures. Other concepts, such as expressive propagation and reflection, are also introduced. The author even mentions that debugging introduces challenges when dealing with scoping, but these advanced binding concepts support scoping across time. A new omniscient debugger could also be designed that would allow a developer to go both backward and forward in time, while looking at all of the scoping strategies affected. Overall, this is a very insightful paper. Online Computing Reviews Service

        Access critical reviews of Computing literature here

        Become a reviewer for Computing Reviews.

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in

        Full Access

        • Published in

          cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 44, Issue 12
          DLS '09
          December 2009
          107 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/1837513
          Issue’s Table of Contents
          • cover image ACM Conferences
            DLS '09: Proceedings of the 5th symposium on Dynamic languages
            October 2009
            118 pages
            ISBN:9781605587691
            DOI:10.1145/1640134
            • Program Chair:
            • James Noble

          Copyright © 2009 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 26 October 2009

          Check for updates

          Qualifiers

          • research-article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader
        About Cookies On This Site

        We use cookies to ensure that we give you the best experience on our website.

        Learn more

        Got it!