Quiz #2
1a)
Draw the environment diagram created by the following expressions
evaluated in order. Draw everything created even if it isn't reachable
at the end. Draw box and pointer diagrams to represent pairs. You may
redraw atoms instead of having multiple pointers pointing to one atom.
> (define (quiz-cons a b)
(let ((cons (cons a b)))
(lambda (mesg)
(define wasted 6)) ))
(cond ((eq? 'bark mesg) b)
((eq? 'woof mesg) a)
((eq? 'cons mesg) cons)
(else (error "ERR" mesg)) )
> (define apple (quiz-cons 'apple 'core))
> (define no-apple (quiz-cons 'apple "Oh! There's more!"))
> (cdr (no-apple 'cons))
> (define ghastly (cons (apple 'bark) (no-apple 'woof)))
> (set-car! ghastly apple)
1b)
Define the selectors quiz-car and quiz-cdr so that the
object created by quiz-cons mimics a pair, except for lacking
mutators.
2)
Draw the concurrencty diagram for:
(Note: This is not in the book.)
(parallel-execute-and-block fn1
(begin fn2
(parallel-execute-and-block fn1 fn4))
fn3)
Given that fn1 and fn2 share the same serializer S1, and fn3, fn2, and
fn4 share the same serializer S2.