首页> 外文会议>Advanced Functional Programming >Generic Program Transformation
【24h】

Generic Program Transformation

机译:通用程序转换

获取原文

摘要

When writing a program, especially in a high level language such as Haskell, the programmer is faced with a tension between abstraction and efficiency. A program that is easy to understand often fails to be efficient, while a more efficient solution often compromises clarity. Fortunately Haskell permits us to reason about programs, so that we can start out with a program that is clear but inefficient, and transform it into a program that is efficient, but perhaps less readable. Indeed, such a transformational style of programming is as old as the subject of functional programming itself. Programs developed in this style continue to suffer from a lack of readability, however: typically a functional programmer will develop his program on the back of an envelope, and only record the final result in his code. Of course he could document his ideas in comments, but as we all know, this is rarely done. Furthermore, when the programmer finds himself in a similar situation, using the same technique to develop a new piece of code, there is no way he can reuse the development recorded as a comment. We claim that there is a handful of techniques that functional programmers routinely use to transform their programs, and that these techniques can themselves be coded as meta programs, allowing one to reuse the same optimisation technique on different pieces of code. In these lectures we shall explore this claim, and ways in which such meta programs might be implemented. The structure of these notes is as follows. We first discuss three motivating examples, to clarify what type of optimisation we have in mind, and how an inefficient program might be annotated with transformations that effect the optimisation. Next, we discuss how the application of transformations can be mechanised. Our main design decision at this point is that transformations are never applied backwards. These ideas are then put to practice in a series of practical assignments, with a toy transformation system especially developed to accompany these notes. Finally, we discuss the matching problem in some detail, and explain how we have chosen to circumvent the undecidability inherent in matching of λ-terms. Throughout, we shall take a cavalier attitude towards semantics. In particular, we have chosen to ignore all issues of strictness: some of our transformation rules ought to state side conditions about strictness. While it is admittedly incorrect to ignore such side conditions, they would clutter the presentation and detract from the main thesis of these lectures.
机译:在编写程序时,尤其是在使用高级语言(例如Haskell)编写程序时,程序员面临抽象与效率之间的紧张关系。易于理解的程序通常效率不高,而更有效的解决方案通常会损害清晰度。幸运的是,Haskell允许我们对程序进行推理,以便我们可以从一个清晰但效率低的程序开始,然后将其转换为一个高效但可读性较低的程序。确实,这种变换式的编程风格与功能性编程本身的主题一样古老。但是,以这种风格开发的程序仍然缺乏可读性:通常,功能程序员会在信封的背面开发程序,并且只将最终结果记录在他的代码中。当然,他可以在评论中记录他的想法,但是众所周知,这很少完成。此外,当程序员发现自己处于类似情况时,使用相同的技术来开发新的代码片段,则他无法重用记录为注释的开发内容。我们声称功能程序员通常使用几种技术来转换程序,这些技术本身可以编码为元程序,从而允许在不同的代码段上重复使用相同的优化技术。在这些讲座中,我们将探讨这种主张以及实现此类元程序的方式。这些注释的结构如下。我们首先讨论三个激励示例,以阐明我们所考虑的优化类型,以及如何通过影响优化的转换来注释效率低下的程序。接下来,我们讨论如何机械化转换的应用。在这一点上,我们的主要设计决定是永远不要向后应用转换。然后,通过一系列实际作业将这些想法付诸实践,并专门开发了玩具转换系统来配合这些说明。最后,我们将详细讨论匹配问题,并说明如何选择避免λ项匹配中固有的不确定性。在整个过程中,我们将对语义持谨慎态度。特别是,我们选择忽略所有严格性问题:我们的某些转换规则应说明严格性方面的附带条件。虽然忽略这样的附带条件是不正确的,但它们会使报告混乱,并有损于这些演讲的主要论题。

著录项

相似文献

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

客服邮箱:kefu@zhangqiaokeyan.com

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

  • 服务号