Check out the new USENIX Web site.

Appendix A

We briefly review some aspects of ML syntax, enough to allow the examples to be read by someone not familiar with ML.

Here is the first example of FPIC in the paper:

box 1.0 2.0 hseq circle 1.5 vseq
     label "\\Huge Hello!" (oval 2.0 1.0);

Function application in ML is indicated by juxtaposition. Here, box is a two-argument function applied to arguments 1.0 and 2.0, circle is a one-argument function, label and oval are two-argument functions. hseq and vseq are infix operators. As in many languages, backslash is an escape character so it must be doubled within quotes.

Function application (juxtaposition) has a high precedence, so that the above expression is equivalent to

(box 1.0 2.0) hseq (circle 1.5) vseq
     (label """Huge Hello!" (oval 2.0 1.0));

Note that that subexpression oval 2.0 1.0 must be parenthesized, however, because otherwise the last part of the expression would be parenthesized as

(label "\\Huge Hello!" oval) 2.0 1.0;

This produces a type error, because the second argument to label must be a picture, and oval is not a picture (rather, it is a function from two reals to a picture).

Top level definitions of variables are signalled by the word val, as in

val nose = dtriangle;

Functions are usually introduced by the keyword fun, as in

fun drawtree root subtrees = ...

The let expression is used to introduce a temporary name.

let val v = e1 in e2 end 

binds the value of e1 to v and then evaluates e2, returning its value.

Structures are of two kinds: tuples and lists. Tuples are written with parentheses, as in (1.0, 1.5). Lists are written with square brackets, as in [dbox, dcircle, dbox].

We occasionally use the syntax fn var => expr to define functions anonymously, usually when applying map. Thus, map (fn var => expr) L applies the function that takes var to expr to each element of the list L.

ML allows for user-defined infix operators, as in

infix 6 cseq;

The "6" gives the precedence of the operator (in the range 0 to 9).

Lastly, two details about built-in operators: The tilde character (~) is the unary negation operator. Carat (^) is the string concatenation operator.


[ Prev | Top | Next ]