Advertisement

Modules, Macros and Lisp

  • Christian Queinnec
  • Julian Padget

Abstract

Many modern languages offer a concept of modules to encapsulate a set of definitions and make some of them visible from outside. Associated to modules are directives ruling importations and exportations as well as controlling other capabilities like renaming or qualified notation. We propose here a language to handle sets of named locations with the aim of describing precisely which locations are to be shared between modules and under which local names they are known. The language is symmetric for imports and exports. It is also extensible since it provides a framework to handle named locations. Mutability, for instance, can readily be expressed thanks to a simple extension of our language.

Another more subtle extension is to offer a protocol for modules with “macros.” Macros allow a user to extend the syntax of a language by providing rewriting rules expressed as computations performed on the representation of programs. Lisp is a language offering macros and much of its extensibility stems from them. However, many problems arise from macros, amongst them being the exact definition of when, where and how the macroexpansion is done to turn the body of a module using extended syntaxes into a regular form in the bare, unextended language.

This paper presents, in the framework of Lisp, a definition of modules offering tight control over module environments as well as a precise semantics of separate compilation and macroexpansion. These new (for Lisp) capabilities definitely add some power relative to the management of name spaces but also justify compiling optimizations (inlining, partial evaluation etc.) and, above all, turn Lisp into a language suitable for application delivery since applications are finite collections of modules. Our proposal contributes to a vision of Lisp composed of a multitude of linked and reusable modules. Our results concerning name space management and macros can also be applied to other languages.

Two different implementations of these concepts exist: in FEEL, the implementation of EuLisp done by the University of Bath and in the idiom of Icsla, a dialect of Lisp designed at INRIA-Rocquencourt and École Polytechnique. This paper reflects the results of the experiments carried out in these systems during the last year.

Keywords

Proper Part Module Environment Module Body Qualified Notation Partial Evaluator 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

Bibliography

  1. [Clinger & Rees, 1991]
    William Clinger, Jonathan Rees, Macros That Work, Eighteenth Annual ACM Symposium on Principles of Programming Languages, Orlando, Florida, January 1991, pp 155–162.Google Scholar
  2. [Curtis & Rauen, 1990]
    Pavel Curtis, James Rauon, A Module System for Scheme, 1990 ACM Conference on Lisp and Functional Programming, Nice, Prance, June 1990, pp 13–19.Google Scholar
  3. [Dybvig et al, 1988]_R. Kent Dybvig, Daniel P. Friedman, Christopher T. Haynes, Expansion-Passing-Style: A General Macro Mechanism, Lisp and Symbolic Computation, Vol. 1, No. 1, June 1988, pp 53–76.CrossRefGoogle Scholar
  4. [Kohlbecker et al, 1986]_Eugene Kohlbecker, Daniel P. Friedman, Matthias Felleisen, Bruce Duba, Hygienic Macro Expansion, Proceedings of 1986 ACM Conference on Lisp and Functional Programming, pp 151–161, ACM Press, New York, 1986.CrossRefGoogle Scholar
  5. [Matthews, 1983]
    Matthews D.C.J, Programming Language Design with Polymorphism, University of Cambridge Computer Laboratory’ Technical Report. No. 49, 1983.Google Scholar
  6. [Queinnec & Padget, 1990]
    Christian Queinuec, Julian Padget, A Model of Modules and Macros for Lisp, Bath Computing Group Technical Report 90-36, University of Bath, UK.Google Scholar
  7. [Queinnec, 1990]
    Christian Queinnec, Compilation of Non-Linear, Second Order Patterns on S-Expressions, International Workshop PULP’ 90, Linköping, Sweden, August 1990, Lecture Notes in Computer Science 456, Springer-Verlag, pp 340–357.Google Scholar
  8. [Rees & Clinger 1986]
    Jonathan A. Rees, William dinger, Revised3 Report on the Algorithmic Language Scheme, ACM SIGPLAN Notices. 21, 12, Dec 86, pp 37–79, ACM Press, New York, 1986.Google Scholar
  9. [Steele, 1990]
    Steele G.L. Jr., Common Lisp the language, Second Edition, Digital Press, 1990.Google Scholar

Copyright information

© Springer Science+Business Media New York 1992

Authors and Affiliations

  • Christian Queinnec
    • 1
  • Julian Padget
    • 2
  1. 1.École Polytechnique & INRIA-RocquencourtFrance
  2. 2.University of BathUK

Personalised recommendations