Concepts of Programming Languages

(Sean Pound) #1

15.7 ML 701


This expression evaluates to (a (* 3 4) c). However, the following
expression:

`(a ,(* 3 4) c)

evaluates to (a 12 c).
LISP implementations have a front end called the reader that transforms
the text of LISP programs into a code representation. Then, the macro calls in
the code representation are expanded into code representations. The output
of this step is then either interpreted or compiled into the machine language
of the host computer, or perhaps into an intermediate code than can be inter-
preted. There is a special kind of macro, named reader macros or read macros,
that are expanded during the reader phase of a LISP language processor. A
reader macro expands a specific character into a string of LISP code. For exam-
ple, the apostrophe in LISP is a read macro that expands to a call to QUOTE.
Users can define their own reader macros to create other shorthand constructs.
Common LISP, as well as other LISP-based languages, have a symbol data
type. The reserved words are symbols that evaluate to themselves, as are T and
NIL. Technically, symbols are either bound or unbound. Parameter symbols are
bound while the function is being evaluated. Also, symbols that are the names
of imperative-style variables and have been assigned values are bound. Other
symbols are unbound. For example, consider the following expression:

(LIST '(A B C))

The symbols A, B, and C are unbound. Recall that Ruby also has a symbol data
type.
In a sense, Scheme and Common LISP are opposites. Scheme is far smaller
and semantically simpler, in part because of its exclusive use of static scoping,
but also because it was designed to be used for teaching programming, whereas
Common LISP was meant to be a commercial language. Common LISP has
succeeded in being a widely used language for AI applications, among other
areas. Scheme, on the other hand, is more frequently used in college courses on
functional programming. It is also more likely to be studied as a functional lan-
guage because of its relatively small size. An important design goal of Common
LISP that caused it to be a large language was the desire to make it compatible
with several of the dialects of LISP from which it was derived.
The Common LISP Object System (CLOS) (Paepeke, 1993) was developed
in the late 1980s as an object-oriented version of Common LISP. This language
supports generic functions and multiple inheritance, among other constructs.

15.7 ML


ML (Milner et al., 1990) is a static-scoped functional programming language,
like Scheme. However, it differs from LISP and its dialects, including Scheme,
in a number of significant ways. One important difference is that ML is a
Free download pdf