Using TEX`s language within a course about

Using TEX`s language within a course about
Jean-Michel Hufflen
Using TEX’s language within a course
about functional programming
We are in charge of a teaching unit, entitled Advanced
Functional Programming, for 4th-year university
students in Computer Science. This unit is optional
within the curriculum, so students attending it are
especially interested in programming. The main
language studied in this unit is Scheme, but an
important part is devoted to general features, e.g.,
lexical vs. dynamic scoping, limited vs. unlimited extent,
call by value vs. call by name or need, etc. As an
alternative to other programming languages, TEX allows
us to show a language where dynamic and lexical
scoping—\def vs. \edef—coexist. In addition, we can
show how dynamic scoping allows users to customise
TEX’s behaviour. Other commands related to strategies
are shown, too, e.g., \expandafter, \noexpand. More
generally, TEX commands are related to macros in more
classical programming languages, and we can both
emphasise difficulty related to macros and show
non-artificial examples. So TEX is not our unit’s main
focus, but provides significant help to illustrate some
difficult notions.
ative programming—the paradigm implemented within
more ‘traditional’ languages, such as C [16]—emphasises
changes in state. Many universities include courses about
functional programming, examples being reported in [35].
Besides, such languages are sometimes taught as first
programming languages, according to an approach comparable to [1, 8, 32] in the case of Scheme.
Let us remark that some tools developed as part of
TEX’s galaxy have already met functional programming:
cl-bibtex [18], an extension of BibTEX—the bibliography
processor [26] usually associated with the LATEX word
processor [20]—is written using ansi2 Common Lisp [7];
x ındy, a multilingual index processor for documents written using LATEX [24, § 11.3] is based on Common Lisp, too;
BibTEX2html [4], a converter from .bib format—used by
the bibliography database files of BibTEX—to html,3 is
written in caml4 [21]; MlBibTEX,5 , a re-implementation
of BibTEX focusing on multilingual features [11] is written in Scheme [15]; as another example, Haskell6 [28]
has been used in [38]; last but not at least, there were
proposals for developing NT S 7 —a re-implementation of
Functional programming, TEX programming, lexical vs.
TEX—using clos,8 an object-oriented system based on
dynamic scope, macros, evaluation strategies.
Common Lisp [39].
The unit we mentioned above is entitled Advanced
Functional Programming.9 It is an optional unit for 4thyear university students in Computer Science, part of the
curriculum proposed at the University of Franche-Comté,
If we consider programming in TEX [17], we have to at the Faculty of Science and Technics, located at Besanadmit that this language is old-fashioned, and programs çon, in the east of France. Most of these students already
are often viewed as rebuses, as shown in the Pearls of TEX know a functional programming language: Scheme, beprogramming demonstrated at BachoTEX conferences.1 cause they attended a unit introducing this language in
Some interesting applications exemplifying this language the 2nd academic year in Computer Science.10 Other
can be found in [19, 30], but as noticed in [5], ‘some of students, who attended the first two university years at
these programming tricks are ingenious and even elegant. Belfort, know caml. So this unit is not an introductory
However [. . . ] it is time for a change’.
course; we delve thoroughly into functional programSo, at first glance, it may be strange to use some ex- ming.
amples of TEX programming within a present-day course
devoted to Functional programming. Let us recall that
In the next section, we expose the ‘philosophy’ of our
this programming paradigm treats computation as the unit. Then we summarise the features of TEX that are
evaluation of mathematical functions, avoiding state and useful within this unit and discuss our choice of TEX.
mutable data as much as possible. Functional program- Reading this article only requires basic knowledge of
ming emphasises functions’ application, whereas imper- programming; readers who would like to go thoroughly
Using TEX’s language within a course about functional programming
(define (factorial x)
;; Returns x! if x is a natural number, the ‘false’
;; value otherwise.
(and (integer? x) (not (negative? x))
(let tr-fact ((counter x)
(acc 1))
;; Returns acc * counter!.
(if (zero? counter)
(tr-fact (- counter 1)
(* acc counter))))))
Figure 1. The factorial function, written using Scheme.
into Scheme constructs we have used throughout our
examples can refer to [32], very didactic. Of course, the
indisputable reference about TEX commands is [17].
Our unit’s purpose
Functional programming languages have a common root
in the λ-calculus, a formal system developed in the 1930s
by Alonzo Church to investigate function definition, function application, and recursion [3]. However, these programming languages are very diverse, some—e.g., the Lisp
dialects11 —are dynamically typed,12 some—e.g., Standard ML13 [27], caml, Haskell—are strongly typed14 and
include a type inference mechanism: end-users do not
have to make precise the types of the variables they use,
they are inferred by the type-checker; in practice, endusers have to conceive a program using a strongly typed
approach because if the type-checker does not succeed in
associating a type with an expression, this expression is
proclaimed incorrect. As examples, Fig. 1 (resp. 2) show
how to program the factorial function in Scheme (resp.
Common Lisp). In both cases, the factorial function we
give can be applied to any value, but returns the factorial
of this value only if it is a non-negative integer, otherwise,
the result is the ‘false’ value. Fig. 3 gives the same function in Standard ML: it can only be applied to an integer,
as reported by the type-checker (see the line beginning
with ‘>’).
(defun factorial (x)
"Behaves like the namesake function in Scheme
(cf. Fig. 1)."
(integerp x) (not (minusp x))
(labels ((tr-fact (counter acc)
;; The labels special form of
;; Common Lisp introduces local
;; recursive functions [33, § 7.5].
(if (zerop counter)
(tr-fact (- counter 1)
(* acc counter)))))
(tr-fact x 1))))
Figure 2. The factorial function in Common Lisp.
know. Besides, this unit ends with some advanced features of this language: delayed evaluation, continuations,
hygienic macros [9]. In addition, this choice allows us
to perform a demonstration of dsssl15 [13], initially designed as the stylesheet language for sgml16 texts. These
students attended a unit about xml and xslt17 [36] the
year before, and dsssl—which may be viewed as xslt’s
ancestor—is based on a subset of Scheme, enriched by
specialised libraries.
When we begin to program, the language we are learning is always shown as finite product. It has precise rules,
precise semantics, and is consistent. According to the
language used, some applications may be easy or difficult
to implement. When you put down a statement, running
it often results in something predictable. That hides an
important point: a language results from some important
choices: does it use lexical or dynamic scoping, or both?
To illustrate this notion with some examples in TEX, that
is the difference between the commands \firstquestion
and \secondquestion in Fig. 4. The former can be related
to lexical scoping, because it uses the value associated
with the \state command at definition-time and produces:
You’re happy, ain’t U?
whereas the latter can be related to dynamic scoping,
A course explaining the general principles of func- because it uses the value of the \state command at runtional programming with an overview of some existing time and yields:
functional programming languages would be indigestible
You’re afraid, ain’t U?
for most students, since they could only with difficulty become familiar with several languages, due to the amount
Students find this notion difficult: some know that
of time that can be allocated to each unit. In addition, the- they can redefine a variable by means of a let form
oretical notions without practice would not be very useful. in Emacs Lisp [22], but they do not realise that this
So, our unit’s first part is devoted to the λ-calculus’ bases would be impossible within lexically-scoped languages
[10]. Then, all the practical exercises are performed with such as C or Scheme. In other words, they do not have
only one language, Scheme, which most students already transversal culture concerning programming languages,
Jean-Michel Hufflen
fun factorial x =
(* If x is a negative integer, the predefined
exception Domain is raised [27, §§ 4.5–4.7]. The
internal function tr_fact is defined by means of
pattern matching [27, § 4.4].
if x < 0 then raise Domain
else let fun tr_fact 0 acc = acc |
tr_fact counter acc =
tr_fact (counter - 1)
acc * counter
in tr_fact x 1
end ;
> val factorial = fn : int -> int
\edef\firstquestion{You’re \state, ain’t U?\par}
\def\secondquestion{You’re \state, ain’t U?\par}
Figure 4. Lexical and dynamic scope within TEX.
Figure 5. Using TeX’s \global command.
Figure 3. The factorial function in Standard ML.
You’re \noexpand\state, ain’t U?\par}
they see each of them as an independent cell, a kind of
black box.
and this command \thirdquestion behaves exactly like
\secondquestion (cf. Fig. 4).
A second construct, useful for a point of view related
to conception, is \global, shown in Fig. 5, because it
The central part of our unit aims to emphasise these allows ‘global’ commands to be defined within local enchoices: what are the consequences of a lexical (resp. dy- vironments. There is an equivalent method in Scheme,
namic) scope? If the language is lexical (resp. dynamic), but not naturally: see Appendix. Let us go on with this
what kinds of applications are easier to be implemented? figure; any TEXnician knows that \thisyear no longer
Likewise, what are the advantages and drawbacks of the works if ‘\edef’ is replaced by ‘\def’. This illustrates that
call-by-value18 strategy vs. call-by-name? In the lan- TEX commands have limited extent.
guage you are using, what is variables’ extent?19 Of
Nuances related to notion of equality exist in TEX: let
course, all the answers depend on the programming languages considered. But our point of view is that a course \a be a command already defined:
based on Scheme and using other examples in TEX may \let\b\a
be of interest.
TEX’s features shown
As mentioned above, \def and \edef allow us to illustrate
the difference between lexical and dynamic scope. Most
present-day programming languages are lexical, but we
can observe that the dynamic scoping allows most TEX
commands to be redefined by end-users. The dynamic
scope is known to cause variable captures,20 but TEX is
protected against undesirable redefinitions by its internal
commands, whose names contains the ‘@’ character. Of
course, forcing these internal commands’ redefinition is
allowed by the \makeatletter command, and restoring
TEX’s original behaviour is done by the \makeatother
If we are interested in implementation considerations,
the commands within an \edef’s body are expanded, so
this body is evaluated as far as possible.21 To show this
point, we can get dynamic scope with an \edef command by preventing command expansion by means of
the former expresses that \a and \b are ‘physically’ equal,
it allows us to retain \a’s definition, even it is changed
afterwards; the latter expresses an equality at run-time,
ensuring that the commands \c and \a are identical, even
if \a changes.22
Scheme’s standard does not allow end-users to know
whether or not a variable x is bound.23 A TEXnician
would use:
\expandafter\ifx\csname x\endcsname\relax...%
For beginners in programming with TEX, this is quite a
complicated statement requiring the commands \relax
and \ifx to be introduced. However, that leads us to
introduce not only the construct \csname...\endcsname,
but also \expandafter, which may be viewed as kind of
call by value. A simpler example of using this strategy is
given by:
\uppercase\expandafter{\romannumeral 2009}
—which yields ‘MMIX’—since this predefined command
\uppercase is given its only argument as it is; so
Using TEX’s language within a course about functional programming
putting the \expandafter command causes this argument to be expanded, whereas removing it would produce ‘mmix’, because \uppercase would leave the group
{\romannumeral 2009} untouched, then \romannumeral
would just be applied to 2009. That is, TEX commands are
macros24 in the sense of ‘more classical’ programming
The last feature we are concerned with is mixfixed
terms, related to parsing problems and priorities. TEX can
put mixfixed terms into action by means of delimiters in
a command’s argument, as in:
Our unit is viewed as theoretical, whereas other optional
units are more practical, so only a few students attend
ours. But in general, students who choose it do not regret
it, and in fact enjoy it. They say that they have clear ideas
about programming after attending it. Some students
view our examples in TEX as a historical curiosity since
this language is quite old and originates from the 1980s,
but they are surprised by its expressive power. Some, that
are interested in using TEX more intensively, can connect
programming in TEX to concepts present in more modern
As shown in the previous section, we use TEX as
a ‘cultural complement’ for alternative constructs
and implementations. Sometimes, we explain differences by historical considerations: for example,
the difference between \def and \long\def—that is,
the difference in LATEX between \textbf{. . . } and
\begin{bfseries}...\end{bfseries}—comes from performance considerations, since at the time TEX came out,
computers were not as efficient as today. Nevertheless,
are there other languages that could be successfully used
as support of our unit? Yes and no.
An interesting example could be Common Lisp. Nevertheless, this language is less used now than some years
ago, and it is complexified by the use of several namespaces.25 Besides, this language’s initial library is as big
as possible; it uses old constructs.26 That is why we give
some examples in Common Lisp, but prefer for our course
to be based on Scheme, which is ‘the’ modern Lisp dialect,
from our point of view.
Concerning the coexistence of lexical and dynamic
variables, the Perl 27 language [37] provides it. In addition, it has been successfully used to develop large software packages, so examples could be credible. However, it
seems to us that dynamic variables in Perl are rarely used
in practice. In fact, the two dynamic languages mainly
used are Emacs Lisp and TEX, in the sense that end-users
may perceive this point. From our point of view, using
examples in Emacs Lisp requires good knowledge about
the emacs28 editor, whereas we can isolate, among TEX’s
features, the parts that suit us, omitting additional details
about TEX’s tasks. Likewise, such an approach would be
more difficult with Perl.
When I decided to use TEX to demonstrate ‘alternative’
implementations of some features related to programming, I was quite doubtful about the result, even if I
knew that some were interested. But feedback was positive, some students were encouraged to go thoroughly
into implementing new TEX commands for their reports
and asked me for some questions about that. Thanks to
them, they encouraged me to go on with this way in turn.
Appendix: \global in Scheme
In this appendix, we show that a construct like \global in
TEX may be needed. Then we will explain why it cannot
be implemented in Scheme in a ‘natural’ way.
Let us consider that we are handling dimensions, that
is, a number and a measurement unit—given as a symbol—
like in TEX or dsssl. A robust solution consists of using a
list prefixed by a marker—e.g., ((*dimension*) 1609344
mm)—such that all the lists representing dimensions—of
type dimension—share the same head element, defined
once. To put this marker only when the components—a
number and a unit29 —are well-formed, it is better for
the access to this marker to be restricted to the functions
interfacing this structure. So here is a proposal for an
implementation of functions dealing with dimensions:
(let ((*marker* ’(*dimension*)))
(define (mk-dimension r unit)
;; Performs some checks and creates an
;; object of type dimension, whose
;; components are r and unit.
(define (dimension? x)
;; Returns #t if x is of type dimension, #f
;; otherwise.
(define (dimension->mm dimension-0)
Jean-Michel Hufflen
(define mk-dimension)
(define dimension?)
(define dimension->mm)
(let ((*marker* ’(*dimension*)) ; Only the cell’s address is relevant.
‘((cm . ,(lambda (r) (* 10 r))) ; Each recognised unit is associated with a function giving the
(mm . ,values))))
; corresponding length in millimeters.
(set! mk-dimension
(let ((allowed-units (map car allowed-unit-alist)))
(lambda (r unit)
(and (real? r) (>= r 0) (memq unit allowed-units) (list *marker* r unit)))))
(set! dimension? (lambda (x) (and (pair? x) (eq? (car x) *marker*))))
(set! dimension->mm
(lambda (dimension-0) ; dimension-0 is supposed to be of type dimension.
((cdr (assq (caddr dimension-0) allowed-unit-alist)) (cadr dimension-0)))))
Figure 6. Global definitions sharing a common lexical environment in Scheme.
;; Returns the value of dimension-0,
;; expressed in millimiters.
. . . ))
Unfortunately, this does not work, because define special [ 4 ]
forms inside the scope of a let special form are viewed
as local definitions, like \def inside a group in TEX. So,
mk-dimension, dimension?, and dimension->mm become [ 5 ]
inaccessible as soon as this let form is processed. The
solution is to define these three variables globally, and
modify them inside a local environment, as shown in [ 6 ]
Fig. 6.
This modus operandi is quite artificial, because it uses
side effects, whereas functional programming aims to
avoid such as far as possible. But in reality, from a
point of view related to conception, there is no ‘actual’
side effect, in the sense that variables like mk-dimension,
dimension?, and dimension->mm would have been first
given values, and then modified. The first bindings may
be viewed as preliminary declarations;30 however, using
‘global’ declarations for variables introduced within a
local environment would be clearer, as in TEX. To sum up,
such an example illustrates that some use of assignment
forms are not related to actual side effects, and TEX’s
\global command allows us to explain how this example
could appear using a ‘more functional’ form, without any
side effect.31
[ 12 ]
Harold Abelson and Gerald Jay Sussman, with
Julie Sussman: Structure and Interpretation of
Computer Programs. The MIT Press, McGrawHill Book Company. 1985.
[ 10 ]
[ 11 ]
[ 13 ]
Neil Bradley: The Concise sgml Companion.
Addison-Wesley. 1997.
Alonzo Church: The Calculi of LambdaConversion. Princeton University Press. 1941.
Jean-Christophe Filliâtre and Claude Marché:
The BibTEX2html Home Page. June 2006. http:
Jonathan Fine: “TEX as a Callable Function”. In:
EuroTEX 2002, pp. 26–30. Bachotek, Poland. April
Michael J. Gordon, Arthur J. Milner and
Christopher P. Wadsworth: Edinburgh lcf.
No. 78 in lncs. Springer-Verlag. 1979.
Paul Graham: ansi Common Lisp. Series in
Artificial Intelligence. Prentice Hall, Englewood
Cliffs, New Jersey. 1996.
Jean-Michel Hufflen : Programmation fonctionnelle en Scheme. De la conception à la mise en
œuvre. Masson. Mars 1996.
Jean-Michel Hufflen : Programmation fonctionnelle avancée. Notes de cours et exercices.
Polycopié. Besançon. Juillet 1997.
Jean-Michel Hufflen : Introduction au λ-calcul
(version révisée et étendue). Polycopié. Besançon.
Février 1998.
Jean-Michel Hufflen: “A Tour around MlBibTEX
and Its Implementation(s)”. Biuletyn gust,
Vol. 20, pp. 21–28. In BachoTEX 2004 conference.
April 2004.
Jean-Michel Hufflen: “Managing Languages
within MlBibTEX”. tugboat, Vol. 30, no. 1,
pp. 49–57. July 2009.
International Standard iso/iec 10179:1996(e):
dsssl. 1996.
Using TEX’s language within a course about functional programming
[ 14 ]
[ 15 ]
[ 16 ]
[ 17 ]
[ 18 ]
[ 19 ]
[ 20 ]
[ 21 ]
[ 22 ]
[ 23 ]
[ 24 ]
[ 25 ]
[ 26 ]
Java Technology. March 2008. http://java.sun.
Richard Kelsey, William D. Clinger, Jonathan A.
Rees, Harold Abelson, Norman I. Adams iv,
David H. Bartley, Gary Brooks, R. Kent Dybvig,
Daniel P. Friedman, Robert Halstead, Chris
Hanson, Christopher T. Haynes, Eugene Edmund
Kohlbecker, Jr, Donald Oxley, Kent M. Pitman,
Guillermo J. Rozas, Guy Lewis Steele, Jr, Gerald Jay Sussman and Mitchell Wand: “Revised5
Report on the Algorithmic Language Scheme”.
hosc, Vol. 11, no. 1, pp. 7–105. August 1998.
Brian W. Kernighan and Dennis M. Ritchie: The
C Programming Language. 2nd edition. Prentice
Hall. 1988.
Donald Ervin Knuth: Computers & Typesetting.
Vol. A: The TEXbook. Addison-Wesley Publishing
Company, Reading, Massachusetts. 1984.
Matthias Köppe: A BibTEX System in Common
Lisp. January 2003.
Thomas Lachand-Robert : La maîtrise de TEX et
LATEX. Masson. 1995.
Leslie Lamport: LATEX: A Document Preparation
System. User’s Guide and Reference Manual.
Addison-Wesley Publishing Company, Reading,
Massachusetts. 1994.
Xavier Leroy, Damien Doligez, Jacques Garrigue, Didier Rémy and Jéróme Vouillon: The
Objective Caml System. Release 0.9. Documentation and User’s Manual. 2004. http://caml.
Bill Lewis, Dan LaLiberte, Richard M. Stallman
and the GNU Manual Group: gnu Emacs
Lisp Reference Manual for Emacs Version 21.
Revision 2.8. January 2002. http://www.gnu.
John McCarthy: “Recursive Functions of
Symbolic Expressions and Their Computation by
Machine, Part I”. Communications of the ACM,
Vol. 3, no. 4, pp. 184–195. April 1960.
Frank Mittelbach and Michel Goossens, with
Johannes Braams, David Carlisle, Chris A. Rowley, Christine Detig and Joachim Schrod: The
LATEX Companion. 2nd edition. Addison-Wesley
Publishing Company, Reading, Massachusetts.
August 2004.
Chuck Musciano and Bill Kennedy: html
& xhtml: The Definitive Guide. 5th edition.
O’Reilly & Associates, Inc. August 2002.
Oren Patashnik: BibTEXing. February 1988. Part
of the BibTEX distribution.
[ 27 ]
[ 28 ]
[ 29 ]
[ 30 ]
[ 31 ]
[ 32 ]
[ 33 ]
[ 34 ]
[ 35 ]
[ 36 ]
[ 37 ]
[ 38 ]
[ 39 ]
Lawrence C. Paulson: ml for the Working
Programmer. 2nd edition. Cambridge University
Press. 1996.
Simon Peyton Jones, ed.: Haskell 98 Language
and Libraries. The Revised Report. Cambridge
University Press. April 2003.
Erik T. Ray: Learning xml. O’Reilly & Associates,
Inc. January 2001.
Denis B. Roegel : « Anatomie d’une macro » .
Cahiers GUTenberg, Vol. 31, p. 19–27. Décembre
Michael Sperber, William Clinger, R. Kent
Dybvig, Matthew Flatt, Anton van Straaten,
Richard Kelsey, Jonathan Rees, Robert Bruce
Findler and Jacob Matthews: Revised6 Report
on the Algorithmic Language Scheme. September
2007. hhtp://
George Springer and Daniel P. Friedman:
Scheme and the Art of Programming. The mit
Press, McGraw-Hill Book Company. 1989.
Guy Lewis Steele, Jr., with Scott E. Fahlman,
Richard P. Gabriel, David A. Moon, Daniel L.
Weinreb, Daniel Gureasko Bobrow, Linda G.
DeMichiel, Sonya E. Keene, Gregor Kiczales,
Crispin Perdue, Kent M. Pitman, Richard
Waters and Jon L White: Common Lisp. The
Language. Second Edition. Digital Press. 1990.
“TEX Beauties and Oddities. A Permanent Call
for TEX Pearls”. In TEX: at a turning point, or at
the crossroads? BachoTEX 2009, pp. 59–65. April
Simon Thompson and Steve Hill: “Functional
Programming through the Curriculum”. In:
FPLE ’95, pp. 85–102. Nijmegen, The Netherlands.
December 1995.
W3C: xsl Transformations (xslt). Version 2.0.
w3c Recommendation. Edited by Michael H. Kay.
January 2007.
Larry Wall, Tom Christiansen and Jon Orwant:
Programming Perl. 3rd edition. O’Reilly
& Associates, Inc. July 2000.
Halina Wątróbska i Ryszard Kubiak: „Od xml-a
do TEX-a, używając Emacsa i Haskella“. Biuletyn
gust, tom 23, strony 35–39. In BachoTEX 2006
conference. kweicień 2006.
Jiři Zlatuška: “NT S: Programming Languages
and Paradigms”. In: EuroTEX 1999, pp. 241–245.
Heidelberg (Germany). September 1999.
1. The most recent pearls can be found in [34].
2. American National Standards Institute.
3. HyperText Markup Language, the language of Web pages.
[25] is a good introduction to it.
4. Categorical Abstract Machine Language.
5. MultiLingual BibTEX.
6. This language was named after logician Haskell Brooks Curry
7. New Typesetting System. It was finally developed using Java
8. Common Lisp Object System.
9. ‘Programmation fonctionnelle avancée’ in French. In 2009, it
has been renamed to ‘Outils pour le développement’ (Tools for
Development), but changes in the contents are slight.
10. The program of this 2nd academic year unit can be found
in French in [8].
11. ‘Lisp’ stands for ‘LISt Processing, because Lisp dialects’
major structure is linked lists. Their syntax is common and
based on fully-parenthesised prefixed expressions. Lisp’s first
version, designed by John McCarthy, came out in 1958 [23].
This language has many descendants, the most used nowadays
being Common Lisp and Scheme.
12. ‘Dynamically typed’ means that we can know the type of
an object at run-time. Examples are given in Figs. 1 & 2.
13. ‘ml’ stands for ‘MetaLanguage’ and has been initially developed within the formal proof system lcf (Logic for Computable
Functions) [6]. Later on, it appears as an actual programming
language, usable outside this system, and its standardisation
resulted in the Standard ML language.
14. There are several definitions of strong typing. The most used
within functional programming is that the variables are typed
at compile-time. Some courses at the same level are based on
a strongly typed functional programming language, examples
being caml or Haskell. Is that choice better than Scheme? This
is a lively debate. . . but it is certain that these courses do not
emphasise the same notions as a course based on a Lisp dialect.
15. Document Style Semantics Specification Language.
16. Standard Generalised Markup Language. Ancestor of xml
(eXtensible Markup Language); it is only of historical interest
now. Readers interested in sgml (resp. xml) can refer to [2]
(resp. [29]).
17. eXtensible Stylesheet Language Transformations.
18. Nowadays, the call by value is the most commonly used
strategy—in particular, in C and in Scheme—the argument expression(s) of a function are evaluated before applying the function. For example, the evaluation of the expression (factorial
(+ 1 9))—see Fig. 1—begins with evaluating (+ 9 1) into 10,
and then factorial is applied to 10. In other strategies, such as
call by name or call by need, argument expressions are evaluated
whilst the function is applied.
19. The extent of a variable may be viewed as its lifetime: if it is
limited, the variable disappears as soon as the execution of the
block establishing it terminates; if it is unlimited, the variable
exists as long as the possibility of reference remains. In Scheme,
variables have unlimited extent.
20. A variable capture occurs when a binding other than the
expected one is used.
21. On the contrary, Scheme interpreters do not evaluate a
Jean-Michel Hufflen
lambda expression’s body. They use a technique—so-called
lexical closure—allowing the function to retrieve its definition
22. There is another distinction in Scheme, between ‘physical’ (function eq?) and ‘visual’ equality (function equal?) [31,
§ 11.5].
23. Common Lisp allows that about variables and functions, by
means of the functions boundp and fboundp [33, 7.1.1].
24. Macros exist in Scheme: the best way to implement them
is the use of hygienic macros, working by pattern-matching [31,
§§ 11.2.2 & 11.19].
25. As an example of handling several namespaces in Common
Lisp, let is used for local variables, whereas local recursive
functions are introduced by labels, as shown in Fig. 2.
26. For example, there is no hygienic macro in Common Lisp.
27. Practical Extraction Report Language.
28. Editing MACros.
29. . . . although we consider only centimeters and millimeters
in the example given in Fig. 6, for sake of simplicity.
30. In Scheme’s last version, a variable can be defined without
an associated value [31, § 11.2.1]. That was not the case in the
version before [15, § 5.2], so such a variable declaration was
given a dummy value, which enforced the use of side effects.
31. Many data structures, comparable with our type
dimension, are used within MlBibTEX’s implementation, as
briefly sketched in [12]. Another technique, based on messagepassing, allows us to avoid side effects. Only one function
would be defined to manage dimensions, and the three functionalities implemented by mk-dimension, dimension?, and
dimension->mm would be implemented by messages sent to the
general function, the result being itself a function.
Jean-Michel Hufflen
LIFC (EA CNRS 4157),
University of Franche-Comté, 16, route de Gray,
25030 Besançon Cedex, France
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF