skip to main content
10.1145/1111037.1111063acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
Article

Interruptible iterators

Published:11 January 2006Publication History

ABSTRACT

This paper introduces interruptible iterators, a language feature that makes expressive iteration abstractions much easier to implement. Iteration abstractions are valuable for software design, as shown by their frequent use in well-designed data structure libraries such as the Java Collections Framework. While Java iterators support iteration abstraction well from the standpoint of client code, they are awkward to implement correctly and efficiently, especially if the iterator needs to support imperative update of the underlying collection, such as removing the current element. Some languages, such as CLU and C# 2.0, support iteration through a limited coroutine mechanism, but these mechanisms do not support imperative updates. Interruptible iterators are more powerful coroutines in which the loop body is able to interrupt the iterator with requests to perform updates. Interrupts are similar to exceptions, but propagate differently and have resumption semantics. Interruptible iterators have been implemented as part of the JMatch programming language, an extended version of Java. A JMatch reimplementation of the Java Collections Framework shows that implementations can be made substantially shorter and simpler; performance results show that this language mechanism can also be implemented efficiently.

References

  1. Chad Fowler Dave Thomas and Andy Hunt. Programming Ruby: The Pragmatic Programmers' Guide. The Pragmatic Programmers, 2nd edition, 2004. ISBN 0-974-51405-5.Google ScholarGoogle Scholar
  2. Ralph E. Griswold, David R. Hanson, and John T. Korb. Generators in ICON. ACM Transaction on Programming Languages and Systems, 3(2), April 1981. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. James Gosling, Bill Joy, Guy Steele, and Gilad Bracha. The Java Language Specification. Addison Wesley, 2nd edition, 2000. ISBN 0-201-31008-2. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. John B. Goodenough. Exception handling design issues. SIGPLAN Notices, 10(7):41--45, 1975. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Emden R. Gansner and John H. Reppy. The Standard ML Basis Library. Cambridge University Press, October 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Steven Gregory. Parallel Programming in PARLOG. Addison-Wesley, 1987.Google ScholarGoogle Scholar
  7. C. T. Haynes, D. P. Friedman, and M. Wand. Obtaining coroutines from continuations. Journal of Computer Languages, 11(3--4):143--153, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Anders Hejlsberg, Scott Wiltamuth, and Peter Golde. The C# Programming Language. Addison-Wesley, 1st edition, October 2003. ISBN 0321154916.Google ScholarGoogle Scholar
  9. Richard Kelsey, William Clinger, and Jonathan Rees (editors). Revised 5 report on the algorithmic language Scheme. ACM SIGPLAN Notices, 33(9):26--76, October 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. B. Kirkerud. Object-Oriented Programming with SIMULA. Addison-Wesley, 1989. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. B. Liskov et al. CLU reference manual. In Goos and Hartmanis, editors, Lecture Notes in Computer Science, volume 114. Springer-Verlag, Berlin, 1981. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Butler Lampson. A description of the Cedar language: A Cedar language reference manual. Technical Report CSL-83-15, Xerox PARC, December 1983.Google ScholarGoogle Scholar
  13. B. Liskov, R. Atkinson, and R. Scheifler. Aspects of implementing CLU. In Proceedings of the Annual Conference. ACM, 1978. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Jed Liu and Andrew C. Myers. JMatch: Java plus pattern matching. Technical Report TR2002-1878, Computer Science Department, Cornell University, October 2002. Software release at http://www.cs.cornell.edu/projects/jmatch.Google ScholarGoogle Scholar
  15. Jed Liu and Andrew C. Myers. JMatch: Abstract iterable pattern matching for Java. In Proc. 5th Int'l Symp. on Practical Aspects of Declarative Languages (PADL), pages 110--127, New Orleans, LA, January 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. B. Liskov, A. Snyder, R. Atkinson, and J. C. Schaffert. Abstraction mechanisms in CLU. Comm. of the ACM, 20(8):564--576, August 1977. Also in S. Zdonik and D. Maier, eds., Readings in Object-Oriented Database Systems. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Andrew C. Myers, Joseph A. Bank, and Barbara Liskov. Parameterized types for Java. In Proc. 24th ACM Symp. on Principles of Programming Languages (POPL), pages 132--145, Paris, France, January 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. David R. Musser, Gillmer J. Derge, and Atul Saini. The STL Tutorial and Reference Guide. Addison-Wesley, 2nd edition, 2001. ISBN 0-201-37923-6. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Microsoft Corporation. Microsoft C# Language Specifications. Microsoft Press, 2001. ISBN 0-7356-1448-2. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Andrew C. Myers, Barbara Liskov, and Nicholas Mathewson. PolyJ: Parameterized types for Java. Software release, at http://www.cs.cornell.edu/polyj, July 1998.Google ScholarGoogle Scholar
  21. O. Lehrmann Madsen, B. Møller-Pedersen, and K. Nygaard. Object Oriented Programming in the BETA Programming Language. Addison-Wesley, June 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Stephan Murer, Stephen Omohundro, David Stoutamire, and Clemens Szyperski. Iteration abstraction in Sather. ACM Transactions on Programming Languages and Systems, 18(1):1--15, January 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Robin Milner, Mads Tofte, and Robert Harper. The Definition of Standard ML. MIT Press, Cambridge, MA, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Nathaniel Nystrom, Michael Clarkson, and Andrew C. Myers. Polyglot: An extensible compiler framework for Java. In Görel Hedin, editor, Compiler Construction, 12th International Conference, CC 2003, number 2622 in Lecture Notes in Computer Science, pages 138--152, Warsaw, Poland, April 2003. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. The SML/NJ Fellowship. Standard ML of New Jersey. http://www.smlnj.org/.Google ScholarGoogle Scholar
  26. B. Stroustrup. The C++ Programming Language. Addison-Wesley, 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Sun Microsystems. JDK 5 Java Language Documentation, 2004. http://java.sun.com/j2se/1.5.0/docs/guide/language.Google ScholarGoogle Scholar
  28. M. Shaw, W. Wulf, and R. London. Abstraction and verification in Alphard: Defining and specifying iteration and generators. Comm. of the ACM, 20(8), August 1977. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Guido van Rossum. The Python Language Reference Manual. Network Theory, Ltd., September 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Niklaus Wirth. Programming in Modula-2. Springer Verlag, Berlin, 3rd edition, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. David H. D. Warren, Luis M. Pereira, and Fernando Pereira. Prolog--the language and its implementation compared with Lisp. In Proc. 1977 Symposium on Artificial Intelligence and Programming Languages, pages 109--115, 1977. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Interruptible iterators

            Recommendations

            Comments

            Login options

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

            Sign in
            • Published in

              cover image ACM Conferences
              POPL '06: Conference record of the 33rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages
              January 2006
              432 pages
              ISBN:1595930272
              DOI:10.1145/1111037
              • cover image ACM SIGPLAN Notices
                ACM SIGPLAN Notices  Volume 41, Issue 1
                Proceedings of the 2006 POPL Conference
                January 2006
                421 pages
                ISSN:0362-1340
                EISSN:1558-1160
                DOI:10.1145/1111320
                Issue’s Table of Contents

              Copyright © 2006 ACM

              Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

              Publisher

              Association for Computing Machinery

              New York, NY, United States

              Publication History

              • Published: 11 January 2006

              Permissions

              Request permissions about this article.

              Request Permissions

              Check for updates

              Qualifiers

              • Article

              Acceptance Rates

              Overall Acceptance Rate824of4,130submissions,20%

              Upcoming Conference

              POPL '25

            PDF Format

            View or Download as a PDF file.

            PDF

            eReader

            View online with eReader.

            eReader