skip to main content
research-article

Towards the Essence of Hygiene

Published:14 January 2015Publication History
Skip Abstract Section

Abstract

Hygiene is an essential aspect of Scheme's macro system that prevents unintended variable capture. However, previous work on hygiene has focused on algorithmic implementation rather than precise, mathematical definition of what constitutes hygiene. This is in stark contrast with lexical scope, alpha-equivalence and capture-avoiding substitution, which also deal with preventing unintended variable capture but have widely applicable and well-understood mathematical definitions.

This paper presents such a precise, mathematical definition of hygiene. It reviews various kinds of hygiene violation and presents examples of how they occur. From these examples, we develop a practical algorithm for hygienic macro expansion. We then present algorithm-independent, mathematical criteria for whether a macro expansion algorithm is hygienic. This characterization corresponds closely to existing hygiene algorithms and sheds light on aspects of hygiene that are usually overlooked in informal definitions.

Skip Supplemental Material Section

Supplemental Material

p457-sidebyside.mpg

References

  1. Eli Barzilay, Ryan Culpepper, and Matthew Flatt. Keeping it clean with syntax parameters. In phProceedings of the Twelfth Workshop on Scheme and Functional Programming, October 2011.Google ScholarGoogle Scholar
  2. Alan Bawden and Jonathan Rees. Syntactic closures. In phProceedings of the 1988 ACM Conference on LISP and Functional Programming, LFP '88, pages 86--95, New York, NY, USA, 1988. ACM. ISBN 0--89791--273-X. 10.1145/62678.62687. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. William Clinger. Hygienic macros through explicit renaming. phACM SIGPLAN Lisp Pointers, IV (4): 25--28, October 1991. ISSN 1045--3563. 10.1145/1317265.1317269. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. William Clinger and Jonathan Rees. Macros that work. In phProceedings of the 18th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL '91, pages 155--162, New York, NY, USA, 1991. ACM. ISBN 0--89791--419--8. 10.1145/99583.99607. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Ryan Culpepper. Fortifying macros. phJournal of Functional Programming, 22 (Special Issue 4--5): 439--476, September 2012. ISSN 1469--7653. 10.1017/S0956796812000275. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Ryan Culpepper and Matthias Felleisen. Well-shaped macros. In phProceedings of the Fourth Workshop on Scheme and Functional Programming, pages 59--68, November 2003.Google ScholarGoogle Scholar
  7. Ryan Culpepper and Matthias Felleisen. Taming macros. In Gabor Karsai and Eelco Visser, editors, phGenerative Programming and Component Engineering, volume 3286 of phLecture Notes in Computer Science, pages 225--243. Springer Berlin Heidelberg, 2004. ISBN 978--3--540--23580--4. 10.1007/978--3--540--30175--2_12.Google ScholarGoogle Scholar
  8. Ryan Culpepper and Matthias Felleisen. Fortifying macros. In phProceedings of the 15th ACM SIGPLAN International Conference on Functional Programming, ICFP '10, pages 235--246, New York, NY, USA, 2010. ACM. ISBN 978--1--60558--794--3. 10.1145/1863543.1863577. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. R. Kent Dybvig. Syntactic abstraction: Thecodesyntax-case expander. In Andy Oram and Greg Wilson, editors, phBeautiful Code: Leading Programmers Explain How They Think, Theory in Practice, chapter 25. O'Reilly Media, July 2007. ISBN 978-0--596--51004--6.Google ScholarGoogle Scholar
  10. R. Kent Dybvig, Robert Hieb, and Carl Bruggeman. Syntactic abstraction in Scheme. phLISP and Symbolic Computation, 5 (4): 295--326, December 1993. ISSN 0892--4635 (Print) 1573-0557 (Online). 10.1007/BF01806308. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Murdoch J. Gabbay and Andrew M. Pitts. A new approach to abstract syntax with variable binding. phFormal Aspects of Computing, 13 (3--5): 341--363, July 2002. ISSN 0934--5043 (Print) 1433--299X (Online). 10.1007/s001650200016.Google ScholarGoogle Scholar
  12. Steven E. Ganz, Amr Sabry, and Walid Taha. Macros as multi-stage computations: type-safe, generative, binding macros in MacroML. In phProceedings of the Sixth ACM SIGPLAN International Conference on Functional Programming, ICFP '01, pages 74--85, New York, NY, USA, 2001. ACM. ISBN 1--58113--415-0. 10.1145/507635.507646. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. David Herman. phA Theory of Typed Hygienic Macros. PhD thesis, Northeastern University, Boston, MA, USA, May 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. David Herman and Mitchell Wand. A theory of hygienic macros. In Sophia Drossopoulou, editor, phProgramming Languages and Systems, volume 4960 of phLecture Notes in Computer Science, pages 48--62. Springer Berlin Heidelberg, 2008. ISBN 978--3--540--78738--9. 10.1007/978--3--540--78739--6_4. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Eugene Kohlbecker, Daniel P. Friedman, Matthias Felleisen, and Bruce Duba. Hygienic macro expansion. In phProceedings of the 1986 ACM Conference on LISP and Functional Programming, LFP '86, pages 151--161, New York, NY, USA, 1986. ACM. ISBN 0--89791--200--4. 10.1145/319838.319859. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Eugene E. Kohlbecker and Mitchell Wand. Macro-by-example: Deriving syntactic transformations from their specifications. In phProceedings of the 14th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, POPL '87, pages 77--84, New York, NY, USA, 1987. ACM. ISBN 0--89791--215--2. 10.1145/41625.41632. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Michael Sperber, R. Kent Dybvig, Matthew Flatt, and Anton van Straaten (eds.). Revised$^6$ report on the algorithmic language Scheme, September 2007. URL http://www.r6rs.org/. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Michael Sperber, R. Kent Dybvig, Matthew Flatt, Anton van Straaten, Robby Findler, and Jacob Matthews. Revised\textsuperscript6 report on the algorithmic language Scheme. phJournal of Functional Programming, 19 (Supplement S1): 1--301, August 2009. ISSN 1469--7653. 10.1017/S0956796809990074. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. André van Tonder. phSRFI-72: Hygienic macros, September 2005. URL http://srfi.schemers.org/srfi-72/srfi-72.html.Google ScholarGoogle Scholar

Index Terms

  1. Towards the Essence of Hygiene

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 50, Issue 1
        POPL '15
        January 2015
        682 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2775051
        • Editor:
        • Andy Gill
        Issue’s Table of Contents
        • cover image ACM Conferences
          POPL '15: Proceedings of the 42nd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages
          January 2015
          716 pages
          ISBN:9781450333009
          DOI:10.1145/2676726

        Copyright © 2015 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 14 January 2015

        Check for updates

        Qualifiers

        • research-article

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!