Internal Iteration Externalized

Although it is acknowledged that internal iterators are easier and safer to use than conventional external iterators, it is commonly assumed that they are not applicable in languages without builtin support for closures and that they are less flexible than external iterators. We present an iteration framework that uses objects to emulate closures, separates structure exploration and data consumption, and generalizes on folding, thereby invalidating both the above statements. Our proposed "transfold" scheme allows processing one or more data structures simultaneously without exposing structure representations and without writing explicit loops. We show that the use of two functional concepts (function parameterization and lazy evaluation) within an object-oriented language allows combining the safety and economic usage of internal iteration with the flexibility and client control of external iteration. Sample code is provided using the statically typed Eiffel language.

[1]  Ralph Johnson,et al.  design patterns elements of reusable object oriented software , 2019 .

[2]  Thomas Kofler Robust Iterators in ET++ , 1993, Struct. Program..

[3]  Michael J. Vilot,et al.  Standard template library , 1996 .

[4]  Maarten M. Fokkinga,et al.  Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire , 1991, FPCA.

[5]  Philip Wadler,et al.  Theorems for free! , 1989, FPCA.

[6]  Barbara Liskov,et al.  Program Development in Java - Abstraction, Specification, and Object-Oriented Design , 1986 .

[7]  Yike Guo,et al.  Parallel skeletons for structured composition , 1995, PPOPP '95.

[8]  Peter G. Neumann Risks to the public in computer systems , 1986, SOEN.

[9]  M.N. Sastry,et al.  Structure and interpretation of computer programs , 1986, Proceedings of the IEEE.

[10]  Richard B. Kieburtz,et al.  Programming with Algebras , 1995, Advanced Functional Programming.

[11]  E. R. Mullins Introduction to APL and computer programming , 1979, APLQ.

[12]  Richard C. Waters,et al.  A Method for Analyzing Loop Programs , 1979, IEEE Transactions on Software Engineering.

[13]  Ole Lehrmann Madsen,et al.  Object-oriented programming in the BETA programming language , 1993 .

[14]  Mark Weiss Algorithms, Data Structures, and Problem Solving With C++ , 1996 .

[15]  Thomas Kühne,et al.  A functional pattern system for object-oriented design , 1999 .

[16]  Barbara Liskov,et al.  Abstraction and Specification in Program Development , 1986 .

[17]  Timothy A. Budd,et al.  Multiparadigm programming in Leda , 1994 .

[18]  簡聰富,et al.  物件導向軟體之架構(Object-Oriented Software Construction)探討 , 1989 .

[19]  Henry G. Baker,et al.  Iterators: signs of weakness in object-oriented languages , 1993, OOPS.

[20]  Robert Martin Discovering patterns in existing applications , 1995 .

[21]  Stephen M. Omohundro The Sather Language and Libraries , 1991, TOOLS.

[22]  J. Hopcroft,et al.  Robust Iterators in ET++ , 1992 .

[23]  Dirk Riehle,et al.  Pattern Languages of Program Design 3 , 1997 .

[24]  Alexander A. Stepanov,et al.  C++ Standard Template Library , 2000 .

[25]  K Thomas The Function Object Pattern , 1997 .

[26]  Mark Evered,et al.  Collection types and implementations in object-oriented software libraries , 1998, Proceedings. Technology of Object-Oriented Languages. TOOLS 26 (Cat. No.98EX176).

[27]  Richard S. Bird,et al.  Introduction to functional programming , 1988, Prentice Hall International series in computer science.

[28]  Wilf R. LaLonde Discovering smalltalk , 1994, Benjamin/Cummings series in object-oriented software engineering.

[29]  Stephen M. Omohundro,et al.  Sather Iters: Object-Oriented Iteration Abstraction , 1993 .

[30]  M. P. Zabinski,et al.  Introduction to APL and computer programming , 1977 .