Skip to main content

A Unifying Approach to Goal-Directed Evaluation

  • Conference paper
  • First Online:
Semantics, Applications, and Implementation of Program Generation (SAIG 2001)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 2196))

  • 229 Accesses

Abstract

Goal-directed evaluation, as embodied in Icon and Snobol, is built on the notions of backtracking and of generating successive results, and therefore it has always been something of a challenge to specify and implement. In this article, we address this challenge using computational monads and partial evaluation.

We consider a subset of Icon and we specify it with a monadic semantics and a list monad. We then consider a spectrum of monads that also fit the bill, and we relate them to each other. For example, we derive a continuation monad as a Church encoding of the list monad. The resulting semantics coincides with Gudeman’s continuation semantics of Icon. We then compile Icon programs by specializing their interpreter (i.e., by using the first Futamura projection), using type-directed partial evaluation. Through various back ends, including a run-time code generator, we generate ML code, C code, and OCaml byte code. Binding-time analysis and partial evaluation of the continuation-based interpreter automatically give rise to C programs that coincide with the result of Proebsting’s optimized compiler.

Basic Research in Computer Science (www.brics.dk), funded by the Danish National Research Foundation.

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. Andrew W. Appel. Compiling with Continuations. Cambridge University Press, New York, 1992.

    Google Scholar 

  2. Lawrence Byrd. Understanding the control of Prolog programs. Technical Report 151, University of Edinburgh, 1980.

    Google Scholar 

  3. Mats Carlsson. On implementing Prolog in functional programming. New Generation Computing, 2(4):347–359, 1984.

    MathSciNet  Google Scholar 

  4. Alonzo Church. The Calculi of Lambda-Conversion. Princeton University Press, 1941.

    Google Scholar 

  5. Charles Consel and Olivier Danvy. Tutorial notes on partial evaluation. In Susan L. Graham, editor, Proceedings of the Twentieth Annual ACM Symposium on Principles of Programming Languages, pages 493–501, Charleston, South Carolina, January 1993. ACM Press.

    Google Scholar 

  6. Charles Consel and FranÇois Noёl. A general approach for run-time specialization and its application to C. In Guy L. Steele, editor, Proceedings of the Twenty-Third Annual ACM Symposium on Principles of Programming Languages, pages 145–156, St. Petersburg Beach, Florida, January 1996. ACM Press.

    Google Scholar 

  7. Ron K. Cytron, editor. Proceedings of the ACM SIGPLAN'97 Conference on Programming Languages Design and Implementation, SIGPLAN Notices, Vol. 32, No 5, Las Vegas, Nevada, June 1997. ACM Press.

    Google Scholar 

  8. Olivier Danvy. Type-directed partial evaluation. In John Hatcliff, Torben Æ. Mogensen, and Peter Thiemann, editors, Partial Evaluation-Practice and Theory; Proceedings of the 1998 DIKU Summer School, number 1706 in Lecture Notes in Computer Science, pages 367–411, Copenhagen, Denmark, July 1998. Springer-Verlag.

    Google Scholar 

  9. Olivier Danvy and René Vestergaard. Semantics-based compiling: A case study in type-directed partial evaluation. In Herbert Kuchen and Doaitse Swierstra, editors, Eighth International Symposium on Programming Language Implementation and Logic Programming, number 1140 in Lecture Notes in Computer Science, pages 182–197, Aachen, Germany, September 1996. Springer-Verlag. Extended version available as the technical report BRICS-RS-96-13.

    Google Scholar 

  10. Andrzej Filinski. Representing layered monads. In Alex Aiken, editor, Proceedings of the Twenty-Sixth Annual ACM Symposium on Principles of Programming Languages, pages 175–188, San Antonio, Texas, January 1999. ACM Press.

    Google Scholar 

  11. Ralph E. Griswold and Madge T. Griswold. The Icon Programming Language. Prentice Hall, Inc., 1983.

    Google Scholar 

  12. Ralph E. Griswold and Madge T. Griswold. The Implementation of the Icon Programming Language. Princeton University Press, 1986.

    Google Scholar 

  13. David A. Gudeman. Denotational semantics of a goal-directed language. ACM Transactions on Programming Languages and Systems, 1992.

    Google Scholar 

  14. Robert Hieb, R. Kent Dybvig, and Carl Bruggeman. Representing control in the presence of first-class continuations. In Bernard Lang, editor, Proceedings of the ACM SIGPLAN‘90 Conference on Programming Languages Design and Implementation, SIGPLAN Notices, Vol. 25, No 6, pages 66–77, White Plains, New York, June 1990. ACM Press.

    Google Scholar 

  15. Ralf Hinze. Prological features in a functional setting-axioms and implementations. In Masahiko Sato and Yoshihito Toyama, editors, Third Fuji International Symposium on Functional and Logic Programming (FLOPS‘98), pages 98–122, Kyoto, Japan, April 1998. World Scientific.

    Google Scholar 

  16. John Hughes. A novel representation of lists and its application to the function “reverse”. Information Processing Letters, 22(3):141–144, 1986.

    Article  Google Scholar 

  17. Neil D. Jones, Carsten K. Gomard, and Peter Sestoft. Partial Evaluation and Automatic Program Generation. Prentice-Hall International, 1993. Available online at http://www.dina.kvl.dk/~sestoft/pebook/pebook.html.

  18. David J. King and Philip Wadler. Combining Monads. In John Launchbury and Patrick M. Sansom, editors, Glasgow Workshop on Functional Programming, Workshops in Computing, Ayr, Scotland, 1992. Springer, Berlin.

    Google Scholar 

  19. Mark Leone and Peter Lee. Optimizing ML with run-time code generation. In Proceedings of the ACM SIGPLAN‘96 Conference on Programming Languages Design and Implementation, SIGPLAN Notices, Vol. 31, No 5, pages 137–148. ACM Press, May 1996.

    Google Scholar 

  20. Karoline Malmkjær. Abstract Interpretation of Partial-Evaluation Algorithms. PhD thesis, Department of Computing and Information Sciences, Kansas State University, Manhattan, Kansas, March 1993.

    Google Scholar 

  21. Eugenio Moggi. Computational lambda-calculus and monads. In Proceedings of the Fourth Annual IEEE Symposium on Logic in Computer Science, pages 14–23, Pacific Grove, California, June 1989. IEEE Computer Society Press.

    Chapter  Google Scholar 

  22. Todd A. Proebsting. Simple translation of goal-directed evaluation. In Cytron [7], pages 1–6.

    Google Scholar 

  23. Todd A. Proebsting and Gregg M. Townsend. A new implementation of the Icon language. Technical Report 99-13, University of Arizona, Department of Computer Science, 1999.

    Google Scholar 

  24. John C. Reynolds. Definitional interpreters for higher-order programming languages. Higher-Order and Symbolic Computation, 11(4):363–397, 1998. Reprinted from the proceedings of the 25th ACM National Conference (1972).

    Article  MATH  Google Scholar 

  25. Morten Rhiger. PhD thesis, BRICS PhD School, University of Aarhus, Aarhus, Denmark, 2001. Forthcoming.

    Google Scholar 

  26. Michael Sperber and Peter Thiemann. Two for the price of one: composing partial evaluation and compilation. In Cytron [7], pages 215–225.

    Google Scholar 

  27. Guy L. Steele Jr. Compiler optimization based on viewing LAMBDA as RENAME + GOTO. In Patrick Henry Winston and Richard Henry Brown, editors, Artificial Intelligence: An MIT Perspective, volume 2. The MIT Press, 1979.

    Google Scholar 

  28. Philip Wadler. Comprehending monads. Mathematical Structures in Computer Science, 2(4):461–493, December 1992.

    Article  MATH  MathSciNet  Google Scholar 

  29. Philip Wadler. Monads for functional programming. In Johan Jeuring and Erik Meijer, editors, Advanced Functional Programming, number 925in Lecture Notes in Computer Science, pages 24–52. Springer-Verlag, 1995.

    Google Scholar 

  30. Richard S. Wallace. An easy implementation of pil (PROLOG in LISP). Association for Computing Machinery Special Interest Group on Artificial Intelligence. SIGART NEWSL., (85):29–32, July 1983.

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2001 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Danvy, O., Grobauer, B., Rhiger, M. (2001). A Unifying Approach to Goal-Directed Evaluation. In: Taha, W. (eds) Semantics, Applications, and Implementation of Program Generation. SAIG 2001. Lecture Notes in Computer Science, vol 2196. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-44806-3_7

Download citation

  • DOI: https://doi.org/10.1007/3-540-44806-3_7

  • Published:

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-42558-8

  • Online ISBN: 978-3-540-44806-8

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics