Com Sci 221 — Programming Languages Assignment #7 — Winter 1992 Due Monday, 9 March

1. Show that Pascal is not a strongly typed language, by explaining how to use a value of any type T_{1} in Pascal as if it had type T_{2}, as long as T_{1} and T_{2} have the same number of bits in their internal representations. 1–3 sentences should be enough, but you must include a specific quote and page reference from the Pascal User Manual and Report to justify your answer.

2. Define interesting control structures as higher-order functions in ML. Include at least

(a) While-loops in the style of Pascal,

(b) For-loops in the style of C,

(c) Case-commands in the style of Pascal.

For extra credit, add more sophisticated control structures. For ideas, look at the treatment of exceptions in ML. The goal is not to get a precise implementation of C or Pascal, but rather to reproduce the essential utility of their control structures within ML. Discuss the differences between the ML functions and the procedural-language control structures that they imitate.

3. Redo the sorting programs of problems 3 and 4 in assignment 6, using ML instead of Scheme. Comment on the types involved.