Program transformations in terms of abstract syntax trees compromise referential integrity by introducing variable capture. Variable capture occurs when in the generated program a variable declaration accidentally shadows the intended target of a variable reference. Existing transformation systems either do not guarantee the avoidance of variable capture or impair the implementation of transformations. We present an algorithm called name-fix that automatically eliminates variable capture from a generated program by systematically renaming variables. name-fix is guided by a graph representation of the binding structure of a program, and requires name-resolution algorithms for the source language and the target language of a transformation. name-fix is generic and works for arbitrary transformations in any transformation system that supports origin tracking for names. We verify the correctness of name-fix and identify an interesting class of transformations for which name-fix provides hygiene. We demonstrate the applicability of name-fix for implementing capture-avoiding substitution, inlining, lambda lifting, and compilers for two domain-specific languages.
| Related KIT institution | Institute for Program Structures and Data Organisation (IPD) |
|---|---|
| Language | English |
| KITopen ID | 1000188550 |
| Keywords | Object oriented programming, Problem oriented languages |
| Publisher | Springer |
| ISBN of the conference proceedings | 978-3-662-44201-2 |
| Series | Lecture Notes in Computer Science (LNCS) (8586) ISSN: 0302-9743 |
| Event | 28th European Conference on Object Oriented Programming (ECOOP), Uppsala, Sweden, Jul 28 – Aug 1, 2014 |
| Relations in KITopen | |
| Referenced in | Scopus Dimensions OpenAlex |