Using Prolog as metalanguage for teaching
programming language concepts
Henning Christiansen
Department of Computer Science
Roskilde University, P.O.Box 260, DK-4000 Roskilde, Denmark
We describe our experiences
with a methodology for teaching programming language concepts
in which Prolog is applied as metalanguage.
Prolog can be seen as an integration of a logical specification
language and a collection of practical accessories expected for an
interactive,
general purpose programming environment.
This, together with the easy-to-extend-and-modify
characteristics
of Prolog programs, makes Prolog ideal in a teaching context:
Assuming the students have grasped the overall flavour of Prolog,
specifications written in Prolog are immediately understandable to
them and this understanding can be further supported by running
small examples, either by themselves or by the lecturer using
a projector and running computer session in the lecture room.
We do not pretend to have made new contributions to
the theory of programming language descriptions.
Our semantic descriptions are
closely related to
Plotkin's operational semantics~\cite{plotkin-81}
(see also~\cite{winskel-93}).
But in our setting, these specifications are actually
running interpreters that serve as prototype implementations.
In addition, they are easily extended into prototypes of
programming tools
such as tracers, debuggers, time-measurers, etc.\ so that
these can be characterized in a systematic framework.
The familiar relation between typing/type checking and unification
is also used for describing concise type-checkers with similar
qualities.
In a course on programming languages, Prolog can also serve
as an interesting example of a ``different'' language
compared with standard imperative or object-oriented languages.
In the teaching of Prolog in this context,
it is obvious to emphasize Prolog's inherent meta-circular
facilities such as assert-retract and its approximation to
negation-as-failure and, at the syntactic level,
operator declarations.
The obvious imperfections of some of these facilities are
not a problem: They can be featured in the course as points
of departures for critical discussions of language design
and pragmatics.
Putting emphasis on a mathematically-logical (or simpler, a
set-theoretic) semantics for the core of Prolog helps students
accept our in-Prolog specifications as ``formal'' descriptions.
Finally,
this sort of language definitions serves also the extra
purpose as
strong evidence for the qualities of declarative programming.
In the paper, we describe our experiences with the methodology
giving samples of such language descriptions and explain
how they are applied in our teaching.
In Kacprzyk J., M.
Krawczak and S. Zadrozny (eds.) Issues in Information Technology, EXIT,
Warszawa, 2002, pp. 59-82.
See
pfd.