Abstract
Should special features for exception handling, backtracking, or pattern matching be included in a programming language? This paper presents a method whereby some programs that use these features can be re-written in a functional language with lazy evaluation, without the use of any special features. This method may be of use for practicing functional programmers; in addition, it provides further evidence of the power of lazy evaluation. The method itself is straightforward: each term that may raise an exception or backtrack is replaced by a term that returns a list of values. In the special case of pattern matching without backtracking, the method can be applied even if lazy evaluation is not present. The method should be suitable for applications such as theorem proving using tacticals, as in ML/LCF.
Preview
Unable to display preview. Download preview PDF.
References
Aho, A. V., and Ullman, J. D. Principles of Compiler Design. Addison-Wesley, 1977.
Black, A. P. Exception handling: the case against. D. Phil. dissertation, Oxford University, 1982. Also available as University of Washington technical report TR 82-01-02, 1982.
Bobrow, D. G., and Raphael, B. New programming languages for artificial intelligence research. Computing Surveys, 6(3): 155–174, September 1974.
Friedman, D. P., and Wise, D. S. Cons should not evaluate its arguments. In Michaelson and Milner (editors), Automata, Languages, and Programming, 257–284, Edinburgh University Press, 1976.
Gordon, M. J., Milner, R., and Wadsworth, C. P. Edinburgh LCF. Lecture Notes in Computer Science 78. Springer-Verlag, 1979.
Griswold, R. E. The evaluation of expressions in Icon. ACM Transactions on Programming Languages and Systems, 4(4): 563–584, October 1982.
Griswold, R. E. The evaluation of expressions in Icon. Symposium on Lisp and Functional Programming, ACM, Austin, TX, August 1984.
Henderson, P., and Morris, J. H. A lazy evaluator. in 3'rd Symposium on Principals of Programming Languages, 95–103, ACM, Atlanta, GA, 1976.
Henderson, P. Functional Programming: Application and Implementation. Prentice-Hall, 1980.
Kowalski, R. Algorithm = Logic + Control. Communications of the ACM, 22(7), July, 1979.
Morris, J. H., Schmidt, E., and Wadler, P. L. Experience with an applicative string processing language. 7'th Symposium on Principles of Programming Languages, ACM, Las Vegas, Nevada, 1980.
Rewriting in Cambridge LCF. Science of Computer Programming, 3: 119–149, Sept., 1983.
Turner, D. A. Recursion equations as a programming language. In Darlington, et al (editors), Functional Programming and Its Applications, Cambridge University Press, 1981.
Wadler, P. L. A splitting headache: Strict vs. lazy semantics for pattern matching in lazy functional languages. To appear.
Author information
Authors and Affiliations
Editor information
Rights and permissions
Copyright information
© 1985 Springer-Verlag Berlin Heidelberg
About this paper
Cite this paper
Wadler, P. (1985). How to replace failure by a list of successes a method for exception handling, backtracking, and pattern matching in lazy functional languages. In: Jouannaud, JP. (eds) Functional Programming Languages and Computer Architecture. FPCA 1985. Lecture Notes in Computer Science, vol 201. Springer, Berlin, Heidelberg. https://doi.org/10.1007/3-540-15975-4_33
Download citation
DOI: https://doi.org/10.1007/3-540-15975-4_33
Published:
Publisher Name: Springer, Berlin, Heidelberg
Print ISBN: 978-3-540-15975-9
Online ISBN: 978-3-540-39677-2
eBook Packages: Springer Book Archive