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

Interruptible iterators

Published: 11 January 2006 Publication 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.
[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.
[3]
James Gosling, Bill Joy, Guy Steele, and Gilad Bracha. The Java Language Specification. Addison Wesley, 2nd edition, 2000. ISBN 0-201-31008-2.
[4]
John B. Goodenough. Exception handling design issues. SIGPLAN Notices, 10(7):41--45, 1975.
[5]
Emden R. Gansner and John H. Reppy. The Standard ML Basis Library. Cambridge University Press, October 2004.
[6]
Steven Gregory. Parallel Programming in PARLOG. Addison-Wesley, 1987.
[7]
C. T. Haynes, D. P. Friedman, and M. Wand. Obtaining coroutines from continuations. Journal of Computer Languages, 11(3--4):143--153, 1986.
[8]
Anders Hejlsberg, Scott Wiltamuth, and Peter Golde. The C# Programming Language. Addison-Wesley, 1st edition, October 2003. ISBN 0321154916.
[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.
[10]
B. Kirkerud. Object-Oriented Programming with SIMULA. Addison-Wesley, 1989.
[11]
B. Liskov et al. CLU reference manual. In Goos and Hartmanis, editors, Lecture Notes in Computer Science, volume 114. Springer-Verlag, Berlin, 1981.
[12]
Butler Lampson. A description of the Cedar language: A Cedar language reference manual. Technical Report CSL-83-15, Xerox PARC, December 1983.
[13]
B. Liskov, R. Atkinson, and R. Scheifler. Aspects of implementing CLU. In Proceedings of the Annual Conference. ACM, 1978.
[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.
[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.
[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.
[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.
[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.
[19]
Microsoft Corporation. Microsoft C# Language Specifications. Microsoft Press, 2001. ISBN 0-7356-1448-2.
[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.
[21]
O. Lehrmann Madsen, B. Møller-Pedersen, and K. Nygaard. Object Oriented Programming in the BETA Programming Language. Addison-Wesley, June 1993.
[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.
[23]
Robin Milner, Mads Tofte, and Robert Harper. The Definition of Standard ML. MIT Press, Cambridge, MA, 1990.
[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.
[25]
The SML/NJ Fellowship. Standard ML of New Jersey. http://www.smlnj.org/.
[26]
B. Stroustrup. The C++ Programming Language. Addison-Wesley, 1987.
[27]
Sun Microsystems. JDK 5 Java Language Documentation, 2004. http://java.sun.com/j2se/1.5.0/docs/guide/language.
[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.
[29]
Guido van Rossum. The Python Language Reference Manual. Network Theory, Ltd., September 2003.
[30]
Niklaus Wirth. Programming in Modula-2. Springer Verlag, Berlin, 3rd edition, 1985.
[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.

Cited By

View all
  • (2024)Lexical Effect Handlers, DirectlyProceedings of the ACM on Programming Languages10.1145/36897708:OOPSLA2(1670-1698)Online publication date: 8-Oct-2024
  • (2020)Handling bidirectional control flowProceedings of the ACM on Programming Languages10.1145/34282074:OOPSLA(1-30)Online publication date: 13-Nov-2020
  • (2018)Human Perception of Inertial Mass for Joint Human-Robot Object ManipulationACM Transactions on Applied Perception10.1145/318217615:3(1-20)Online publication date: 13-Apr-2018
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

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
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]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 11 January 2006

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. JMatch
  2. Java
  3. coroutine
  4. exception
  5. logic programming

Qualifiers

  • Article

Conference

POPL06

Upcoming Conference

POPL '26

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)10
  • Downloads (Last 6 weeks)0
Reflects downloads up to 18 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2024)Lexical Effect Handlers, DirectlyProceedings of the ACM on Programming Languages10.1145/36897708:OOPSLA2(1670-1698)Online publication date: 8-Oct-2024
  • (2020)Handling bidirectional control flowProceedings of the ACM on Programming Languages10.1145/34282074:OOPSLA(1-30)Online publication date: 13-Nov-2020
  • (2018)Human Perception of Inertial Mass for Joint Human-Robot Object ManipulationACM Transactions on Applied Perception10.1145/318217615:3(1-20)Online publication date: 13-Apr-2018
  • (2017)Patterns for C Iterator InterfacesProceedings of the 22nd European Conference on Pattern Languages of Programs10.1145/3147704.3147714(1-14)Online publication date: 12-Jul-2017
  • (2016)Embedding goal-directed evaluation through transformationProceedings of the 31st Annual ACM Symposium on Applied Computing10.1145/2851613.2851731(1790-1797)Online publication date: 4-Apr-2016
  • (2014)Accelerating iterators in optimizing AST interpretersACM SIGPLAN Notices10.1145/2714064.266022349:10(727-743)Online publication date: 15-Oct-2014
  • (2014)Accelerating iterators in optimizing AST interpretersProceedings of the 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications10.1145/2660193.2660223(727-743)Online publication date: 15-Oct-2014
  • (2013)Fast RMWs for TSOACM SIGPLAN Notices10.1145/2499370.246219648:6(61-72)Online publication date: 16-Jun-2013
  • (2013)Reconciling exhaustive pattern matching with objectsACM SIGPLAN Notices10.1145/2499370.246219448:6(343-354)Online publication date: 16-Jun-2013
  • (2013)Concurrent libraries with foresightACM SIGPLAN Notices10.1145/2499370.246217248:6(263-274)Online publication date: 16-Jun-2013
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media