

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


UIUC, Department of Computer Science Spring 2006 CS421 Programming Languages Machine Problem Set 5
Assigned: April 03, 2006 Due: April 21, 2006 9:00pm
Upon completion of this MP, you should understand:
In this problem, you will add the ability to define your own types to a (provided) typed interpreter. The suggested steps are:
Example:
(run " lettype ff = (int -> int) ff zero-ff () = proc (int k) 0 ff extend-ff (int k, int val, ff old-ff) = proc (int k1) if zero?(-(k1,k)) then val else (old-ff k1) int apply-ff ( ff f, int k) = (f k) in let ff1 = (extend-ff 1 11 (extend-ff 2 22 (zero-ff))) in (apply-ff ff1 2)" ) 22
This problem is only required for all the graduate students. Undergraduates may do this problem for extra credit. Exercise 5.22 in the book.
Exercise 5.23 In the book. We will not test the case where a static field in the derived class overrides a field in the base class. A solution can be written by adding/changing around 25 lines of code to the starter code. Example:
(run " class c1 extends object static next serial number = 5 field my serial number method get serial number () my serial number method initialize () begin set my serial number = next serial number; set next serial number = add1(next serial number) end class c2 extends c static next to last ser num = sub1(next serial number) method get next to last ser num() next to last ser num let o1 = new c1() o2 = new c1() o3 = new c2()