...
首页> 外文期刊>Information and software technology >Automatic transformation of iterative loops into recursive methods
【24h】

Automatic transformation of iterative loops into recursive methods

机译:自动将迭代循环转换为递归方法

获取原文
获取原文并翻译 | 示例
           

摘要

Context: 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 can be used in industrial projects (i.e., it is automatic, it handles all kinds of loops, it considers exceptions, etc.). Objective: This article describes an industrial algorithm implemented as a Java library able to automatically 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. Method: We describe the changes needed to transform loops of types while/do/for/foreach into recursion. We provide a transformation schema for each kind of loop. Results: Our algorithm is the first public transformation that can be used in industrial projects and faces the whole Java language (i.e., it is fully automatic, it handles all kinds of loops, it considers exceptions, it treats the control statements break and continue, it handles loop labels, it is able to transform any number of nested loops, etc.). This is particularly interesting because some of these features are missing in all previous work, probably, due to the complexity that their mixture introduce in the transformation. Conclusion: Developers should use a methodology when transforming code, specifically when transforming loops into recursion. This article provides guidelines and algorithms that allow them to face different problems such as exception handling. The implementation has been made publicly available as open source.
机译:背景信息:在软件工程中,必须在递归和迭代之间进行适当选择,因为它们的效率和维护是不同的。实际上,开发人员通常需要将迭代转换为递归(例如,在调试中,将调用图分解为迭代);因此,令人惊讶的是,没有一个可以在工业项目中使用的从循环到递归的公共转换(即,它是自动的,可以处理各种循环,可以考虑异常等)。目标:本文介绍了一种工业算法,该算法以Java库的形式实现,能够自动将迭代循环转换为等效的递归方法。描述了针对Java编程语言的转换,但是它足够通用,可以适应允许迭代和递归的许多其他语言。方法:我们描述了将while / do / for / foreach类型的循环转换为递归所需的更改。我们为每种循环提供了一种转换方案。结果:我们的算法是可用于工业项目并面向整个Java语言的第一个公共转换(即,它是全自动的,可以处理各种循环,可以考虑异常,可以处理控制语句的中断和继续,它处理循环标签,能够转换任意数量的嵌套循环等)。这特别有趣,因为以前的所有工作都缺少其中某些功能,这可能是由于它们的混合在转换中引入了复杂性。结论:开发人员在转换代码时应使用一种方法,特别是在将循环转换为递归时。本文提供了指导方针和算法,使它们能够面对不同的问题,例如异常处理。该实现已作为开源公开提供。

著录项

  • 来源
    《Information and software technology》 |2015年第2期|95-109|共15页
  • 作者

    David Insa; Josep Silva;

  • 作者单位

    Departament de Sistemes Informatics i Computacio, Universitat Politecnica de Valencia, Camino de Vera s, E-46022 Valencia, Spain;

    Departament de Sistemes Informatics i Computacio, Universitat Politecnica de Valencia, Camino de Vera s, E-46022 Valencia, Spain;

  • 收录信息
  • 原文格式 PDF
  • 正文语种 eng
  • 中图分类
  • 关键词

    Program transformation; Iteration; Recursion;

    机译:程序转换;迭代;递归;

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号