[plt-scheme] reduction-semantics library changes

From: Jacob Matthews (jacobm at cs.uchicago.edu)
Date: Thu Mar 18 16:22:33 EST 2004

I've just exp-tagged an upgrade to the reduction-semantics library and 
thought it would be a good idea to give everyone who might be using the 
library a heads-up, particularly since some changes make the upgrade 
incompatible with previous versions.

Improvements:

* IMPLICIT NONTERMINAL NAMING

In the pattern language used for describing the left-hand sides of 
reduction rules, an identifier of the form nonterminal_extra is 
implicitly considered equivalent to the pattern
(name nonterminal_extra nonterminal). Identifiers in patterns are no 
longer otherwise allowed to contain underscores.

The rationale behind this change is that it makes the code look more 
like mathematical notation (interpreting an _ in the LaTeX sense of 
beginning a subscript). It also tends to make the left-hand sides of 
reduction patterns much shorter.

(This change has actually been in CVS for a month or so, but not 
announced.)

* GUI IS NOW KNOWN AS TRACES

The functions gui.ss provides are now called traces/* rather than gui/*. 
 The old names weren't particularly good, and we figured it'd be better 
to change them now than later.

* NEW PRETTY PRINTER OPTIONS

There's a new simpler interface for providing alternate printers to the 
traces functions: the pretty-printer may now be a function that accepts 
an s-expression and produces a string that the traces function will use 
as that s-expression's printed representation. The old interface is 
still available. (See threads.ss in the examples directory for a use of 
the new interface.)

* NEW SUBLANGUAGE FOR BUILDING RESULT TERMS IN REDUCTIONS

This is the biggest change. The `term' macro allows result patterns oon 
the right-hand sides of reduction rules analgous to macro result 
patterns, so reduction rules' right-hand sides now look more like their 
left-hand sides. The term macro introduces normal s-expressions just 
like quasiquote does, but in addition to quasiquote's , and ,@ escaping 
mechanisms it also implicitly replaces pattern-bound names with the 
values they are bound to and allows the ... notation macros use for 
splicing elements into terms.

Importantly, `term' is now the ONLY WAY to get the value of a binding 
introduced by a pattern-match, so all existing code will have to change 
to work with the new system. You'll have to rewrite terms so that they 
look like:

(define lang (language (e (+ e e) number)
                                     (c (+ c e) (+ e c))))

(reduction lang
   (in-hole c_1 (+ number_1 number_2))
   (replace (term c_1) (+ (term number_1) (term number_2))))

See the files in the examples subdirectory for more uses of term.

Of course, see the documentation for more details about all these 
changes. If the thought of these changes is making you panic, fear not: 
the old version is still available as a .plt file at

http://people.cs.uchicago.edu/~jacobm/plt/plt-redex-old.plt

-jacob



Posted on the users mailing list.