Skip to main content

Capture-Avoiding and Hygienic Program Transformations

  • Conference paper
ECOOP 2014 – Object-Oriented Programming (ECOOP 2014)

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 8586))

Included in the following conference series:

Abstract

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.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Barzilay, E., Culpepper, R., Flatt, M.: Keeping it clean with syntax parameters. In: Scheme (2011)

    Google Scholar 

  2. Bawden, A., Rees, J.: Syntactic closures. In: LFP, pp. 86–95. ACM (1988)

    Google Scholar 

  3. Clinger, W., Rees, J.: Macros that work. In: POPL, pp. 155–162. ACM (1991)

    Google Scholar 

  4. Czarnecki, K., Helsen, S.: Feature-based survey of model transformation approaches. IBM Systems Journal 45(3), 621–645 (2006)

    Article  Google Scholar 

  5. de Bruijn, N.G.: Lambda calculus notation with nameless dummies, a tool for automatic formula manipulation, with application to the Church-Rosser theorem. Indagationes Mathematicae 75(5), 381–392 (1972)

    Article  MATH  Google Scholar 

  6. de Jonge, M., Visser, E.: A language generic solution for name binding preservation in refactorings. In: LDTA. ACM (2012)

    Google Scholar 

  7. Dybvig, R.K., Hieb, R., Bruggeman, C.: Syntactic abstraction in scheme. Lisp and Symbolic Computation 5(4), 295–326 (1992)

    Article  Google Scholar 

  8. Erdweg, S.: Extensible Languages for Flexible and Principled Domain Abstraction. PhD thesis, Philipps-Universität Marburg (2013)

    Google Scholar 

  9. Erdweg, S., van der Storm, T., Dai, Y.: Capture-avoiding and hygienic program transformations (incl. proofs). CoRR, abs/1404.5770 (2014)

    Google Scholar 

  10. Erdweg, S., et al.: The state of the art in language workbenches. In: Erwig, M., Paige, R.F., Van Wyk, E. (eds.) SLE 2013. LNCS, vol. 8225, pp. 197–217. Springer, Heidelberg (2013)

    Chapter  Google Scholar 

  11. Herman, D.: A Theory of Typed Hygienic Macros. PhD thesis, Northeastern University, Boston, Massachusetts (2012)

    Google Scholar 

  12. Izmaylova, A., Klint, P., Shahi, A., Vinju, J.: M3: An open model for measuring source code artifacts. arXiv:1312.1188, BENEVOL 2013 (2013)

    Google Scholar 

  13. Johnsson, T.: Lambda lifting: Transforming programs to recursive equations. In: Jouannaud, J.-P. (ed.) FPCA 1985. LNCS, vol. 201, pp. 190–203. Springer, Heidelberg (1985)

    Chapter  Google Scholar 

  14. Klint, P., van der Storm, T., Vinju, J.: Rascal: A domain-specific language for source code analysis and manipulation. In: SCAM, pp. 168–177 (2009)

    Google Scholar 

  15. Kohlbecker, E., Friedman, D.P., Felleisen, M., Duba, B.: Hygienic macro expansion. In: LFP, pp. 151–161. ACM (1986)

    Google Scholar 

  16. Lee, B., Grimm, R., Hirzel, M., McKinley, K.S.: Marco: Safe, expressive macros for any language. In: Noble, J. (ed.) ECOOP 2012. LNCS, vol. 7313, pp. 589–613. Springer, Heidelberg (2012)

    Chapter  Google Scholar 

  17. B.C.: d. S. Oliveira and A. Löh. Abstract syntax graphs for domain specific languages. In: PEPM, pp. 87–96. ACM (2013)

    Google Scholar 

  18. Paige, R.F., Kolovos, D.S., Polack, F.A.C.: Metamodelling for grammarware researchers. In: Czarnecki, K., Hedin, G. (eds.) SLE 2012. LNCS, vol. 7745, pp. 64–82. Springer, Heidelberg (2013)

    Chapter  Google Scholar 

  19. Pfenning, F., Elliott, C.: Higher-order abstract syntax. In: PLDI, pp. 199–208. ACM (1988)

    Google Scholar 

  20. Reps, T., Teitelbaum, T., Demers, A.: Incremental context-dependent analysis for language-based editors. TOPLAS 5(3), 449–477 (1983)

    Article  Google Scholar 

  21. Schäfer, M., Ekman, T., de Moor, O.: Sound and extensible renaming for Java. In: OOPSLA, pp. 227–294. ACM (2008)

    Google Scholar 

  22. Sheard, T.: Accomplishments and research challenges in meta-programming. In: Taha, W. (ed.) SAIG 2001. LNCS, vol. 2196, pp. 2–44. Springer, Heidelberg (2001)

    Chapter  Google Scholar 

  23. Shinwell, M.R., Pitts, A.M., Gabbay, M.J.: FreshML: Programming with binders made simple. In: ICFP, pp. 263–274. ACM (2003)

    Google Scholar 

  24. Macko, M., Batory, D.: Scoping constructs for software generators. In: Czarnecki, K. (ed.) GCSE 1999. LNCS, vol. 1799, pp. 65–78. Springer, Heidelberg (2000)

    Chapter  Google Scholar 

  25. Valdera, P.I., van der Storm, T., Erdweg, S.: Tracing model transformations with string origins. In: ICMT. Springer (to appear, 2014)

    Google Scholar 

  26. van den Bos, J., van der Storm, T.: Bringing domain-specific languages to digital forensics. In: ICSE, pp. 671–680. ACM (2011)

    Google Scholar 

  27. van Deursen, A., Klint, P., Tip, F.: Origin tracking. Symbolic Computation 15, 523–545 (1993)

    Article  MATH  Google Scholar 

  28. Wachsmuth, G., Konat, G.D.P., Vergu, V.A., Groenewegen, D.M., Visser, E.: A language independent task engine for incremental name and type analysis. In: Erwig, M., Paige, R.F., Van Wyk, E. (eds.) SLE 2013. LNCS, vol. 8225, pp. 260–280. Springer, Heidelberg (2013)

    Chapter  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

1 Electronic Supplementary Material

Rights and permissions

Reprints and permissions

Copyright information

© 2014 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Erdweg, S., van der Storm, T., Dai, Y. (2014). Capture-Avoiding and Hygienic Program Transformations. In: Jones, R. (eds) ECOOP 2014 – Object-Oriented Programming. ECOOP 2014. Lecture Notes in Computer Science, vol 8586. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-662-44202-9_20

Download citation

  • DOI: https://doi.org/10.1007/978-3-662-44202-9_20

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-662-44201-2

  • Online ISBN: 978-3-662-44202-9

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics