








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!









1
2
4
5
NEW^8
9
;^ interp^ :^ BCFAE^ DefrdSub
Store^ ->^ Value*Store (define^ (interp^ expr
ds^ st) ... [app^ (fun-expr^ arg-expr
(interp-two^ fun-expr
arg-expr^ ds^ st (lambda (fun-val^ arg-val^ st
(local^ [(define^ a^
(malloc^ st))] (interp (closureV-body^ fun-val) (aSub (closureV-param^ fun-val
a (closureV-sc^ fun-val
(aSto^ a arg-val^ st)))))] ...)
11-
;^ interp^ :^ BCFAE^ DefrdSub
Store^ ->^ Value*Store (define^ (interp^ expr
ds^ st) ... [set^ (id^ val-expr) (local^ [(define
a^ (lookup^ id^ ds))] (type-case Store*Value^ (interp^
val-expr^ ds^ st) [vs^ (val^ st) (vs^ val^ (aSto^ a val^ st
17-
(define^ (swap^ x^ y)^ (local^ [(define^
z^ y)] (set! y x) (set! x z))) (local^ [(define^ a^
(swap^ x^ y) (local^ [(define^ z^ (box^
(unbox^ y)))] (set-box!^ y^ (unbox
x)) (set-box!^ x^ (unbox
z)))) (local^ [(define^ a^
(box^10 ))(define b (box^20 ))] (begin ;(swap (box (unbox^ a));(box (unbox^ b))) (swap a b) (unbox a)))
23
Value*Store (define^ (interp^ expr
ds^ st) ... [app^ (fun-expr^ arg-expr
(if^ (id?^ arg-expr) ;^ call-by-ref^
handling^ for^ id^ arg: (type-case Value*Store^ (interp^ fun-expr
ds^ st) [v*s^ (fun-val^ st) (local^ [(define
a (lookup^ (id-name^ arg-expr
)^ ds))] (interp^ (closureV-body
fun-val) (aSub namea (closureV-sc^ fun-val)) st))]) ;^ as^ before: ...)] ...)
24