Due: Wednesday, September 23rd, 2015 11:59pm
Start with store-with.rkt. In the starting program, the representation of the store grows every time that a box’s content is modified with set-box!. Change the implementation of set-box! so that the old value of the box is dropped (i.e., replaced with the new value) instead of merely hidden by the outside-in search order of fetch.
Example:
(test (interp (parse '{let {[b {box 1}]} {begin {set-box! b 2} {unbox b}}}) mt-env mt-store) (v*s (numV 2) (override-store (cell 1 (numV 2)) mt-store)))
Generalize begin to allow one or more sub-expressions, instead of exactly two sub-expressions.
<Expr> = ... | {begin <Expr> <Expr>*}
Example:
(test (interp (parse '{let {[b {box 1}]} {begin {set-box! b {+ 2 {unbox b}}} {set-box! b {+ 3 {unbox b}}} {set-box! b {+ 4 {unbox b}}} {unbox b}}}) mt-env mt-store) (v*s (numV 10) (override-store (cell 1 (numV 10)) mt-store)))
See also the practice mid-term (but it’s not to hand in).
Last update: Tuesday, September 15th, 2015mflatt@cs.utah.edu |