Transforming while/do/for/foreach-Loops into Recursive Methods
David Insa, Josep Silva

TL;DR
This paper presents a comprehensive method to automatically transform all common loop types in Java into equivalent recursive methods, aiding developers in debugging and code analysis.
Contribution
It introduces a novel, general transformation approach for converting various loop constructs into recursion in Java, filling a gap in existing tools.
Findings
Transformation handles all loop types in Java
Method preserves the original loop semantics
Applicable to other languages with iteration and recursion
Abstract
In software engineering, taking a good election between recursion and iteration is essential because their efficiency and maintenance are different. In fact, developers often need to transform iteration into recursion (e.g., in debugging, to decompose the call graph into iterations); thus, it is quite surprising that there does not exist a public transformation from loops to recursion that handles all kinds of loops. This article describes a transformation able to transform iterative loops into equivalent recursive methods. The transformation is described for the programming language Java, but it is general enough as to be adapted to many other languages that allow iteration and recursion. We describe the changes needed to transform loops of types while/do/for/foreach into recursion. Each kind of loop requires a particular treatment that is described and exemplified.
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsParallel Computing and Optimization Techniques · Logic, programming, and type systems · Embedded Systems Design Techniques
