Expressions, Types, and Functions |
We use the programming language Scheme in this material. Therefore it is natural to start with a brief discussion of the family of languages, to which Scheme belongs. This is the Lisp family of languages.
3.1. Lisp
Contents Up Previous Next Slide Subject index Program index Exercise index
Lisp was invented by John McCarthy in the late fifties. In these days the dominating use of computers was for numeric purposes. One of the purposes of Lisp was to support symbolic computation.
As an example of symbolic computation, let us mention the calculation of differentiated mathematical functions. The symbolic derivation of the function f(x) = x * x is the function g(x) = 2 * x. The numeric derivation of f will never deliver the function g on source form. The best we can hope for is some sort of numeric approximation to g, which can be applied to numbers.
It is worth noticing that transformation and compilation of programs also can be considered as symbolic computations. In fact it turns out, that the computer is better suited to do symbolic computations than numeric computations, because the former always can be done exactly, whereas the latter often are inexact.
Today, many Lisp languages are not in use any more. Lisp 1.5 and Interlisp are two of these. 'Lisp' is today used as a family name of all 'Lisp languages', which includes such languages and Emacs Lisp, Common Lisp, and Scheme.
Lisp is the next oldest programming language - only Fortran is older. |
In the past, thousands of programming languages have been invented and tried out. Naturally, many of these are not in active use any more. It is interesting to notice that both Lisp and Fortran are still in widespread use for many different purposes.
Below we will summarize the main characteristics of Lisp.
|
One of the most remarkable facts of Lisp is that the primary data structure in the language - lists - is used for the representation of programs. This is the reason why we use all these parentheses in a Lisp program! Originally, this characteristic program representation was only thought as an intermediate representation, not to be used by the human programmer. It turned out, eventually, that the representation had some very useful properties. Therefore the following 'equation' is an important characteristic of all Lisp languages.
Program = Data = Lists |
3.2. Scheme
Contents Up Previous Next Slide Subject index Program index Exercise index
Scheme is a programming language in the Lisp family. Scheme is formally defined in the Scheme report [Abelson98], which is revised from time to time. Currently, the fifth revision is the most current one. This explains the abbreviation R5RS, which goes something like 'The fifth Revised Report on the Algorithmic Language Scheme'.
Scheme is a small, yet powerful language in the Lisp family |
|
Many people encounter Lisp programming in Emacs Lisp [fsf02] , [fsf02a], because of the need of customizing Emacs in non-trivial ways. Emacs Lisp is an old and primitive dialect of Lisp. Hard core Lisp programmers are also likely to meet Common Lisp, which is much bigger than Scheme. The statement below compares very briefly Common Lisp and Emacs Lisp with Scheme.
Scheme is an attractive alternative to Common Lisp (a big monster) and
Emacs Lisp (the rather primitive extension language of the Emacs text editor). |
The purpose of this exercises is learn the most important practical details of using a Scheme system on Unix. In case you insist to use Windows we will assume that you install the necessary software in your spare time. There is no time available to do that during the course exercises. Further details on installation of Scheme and LAML on Windows.
You will have to choose between DrScheme and MzScheme.
DrScheme is a user friendly environment for creating and running Scheme programs, with lots of menus and lots of help. However, it is somewhat awkward to use DrScheme with LAML. Only use DrScheme in this course if you cannot use Emacs, or if you are afraid of textually, command based tools. Follow this link for further details.
MzScheme is the underlying engine of DrScheme. MzScheme is a simple read-eval-print loop, which let you enter an expression, evaluate and print the result. MzScheme is not very good for debugging and error tracing. MzScheme works well together with Emacs, and there is a nice connection between MzScheme and LAML. MzScheme used with Emacs is preferred on this course. Please go through the following steps:
(load "/pack/laml/emacs-support/dot-emacs-contribution.el")
(html (head (title "A title")) (body (p "A body")))
3.3. References
[Fsf02a] | GNU Emacs Lisp Reference Manual. The Free Software Fundation Inc, May 2002. |
[Fsf02] | Free Software Foundation, "Programming in Emacs Lisp (Second Edition)", January 2002. |
[Abelson98] | Richard Kelsey, William Clinger and Jonathan Rees, "Revised^5 Report on the Algorithmic Language Scheme", Higher-Order and Symbolic Computation, Vol. 11, No. 1, August 1998, pp. 7--105. |