-(let ((pragma
- ; An ordered pair whose first component is the assertion
- ; operator, a unary function, and whose second component
- ; is the meaning of "damn", a thunk.
- (call/cc (lambda (k)
- (cons (lambda (p) p)
- (lambda () (k (cons (lambda (p) (cons (cons 'side-effect 'bad) p))
- (lambda () 'id)))))))))
- (let ((assert (car pragma)) ; this binds assert to the first element of the pair pragma
- (damn (cdr pragma))) ; this binds damn to the second element of the pair pragma
- (assert (cons (cons 'the 'student) (cons 'read (cons 'the (cons (damn) 'book)))))))
-
-We won't do much to explain this. We'll just leave it for you to chew on.
-
-
-
-
- #lang racket
- ;(define damn (lambda () 'id))
- (define damn (lambda () (call/cc (lambda (k)
- ; (k 'id)
- (print "Something's bad")
- (k 'id)
- ))))
-
- (list (list 'the (list (damn) 'man))
- (list 'read
- (list 'the (list (damn) 'book))))
-
-
-
-
-
- #lang racket
- (require racket/control)
-
- (define damn0 (lambda ()
- 'id))
-
- (define damn1 (lambda ()
- (cons '("side effect" bad)
- 'id)))
-
- (define damn2 (lambda () (shift k
- (cons '("side effect" bad)
- (list (k 'id))))))
-
- (define damn3 (lambda () (shift k
- (list (k 'id)
- '("side effect" bad)))))
-
-
-; Now if we use damn0, our compositional semantics will work OK but
-; we don't yet have any affective contribution:
-
- (list "main content" 'i (list 'like (list 'the (damn0) 'boy)))
- ; '("main content" i (like (the id boy)))
-
-
-; If we use damn1, we've added in the affective side-effect:
-
- (list "main content" 'i (list 'like (list 'the (damn1) 'boy)))
- ; '("main content" i (like (the (("side effect" bad) . id) boy)))
-
-; However, the context (list 'the ... 'boy) is now being asked to operate
-; on an element (("side effect" bad) . id), and it may complain it doesn't
-; know what that is. It knows how to use 'id to get (list 'the 'id 'boy),
-; and how to use 'bad to get (list 'the 'bad 'boy), but we're supposed to
-; have something different here.
-
-; To get what we want we need to use (delimited) continuations:
- (reset (list "main content" 'i (list 'like (list 'the (damn2) 'boy))))
- ; '(("side effect" bad) ("main content" i (like (the id boy))))
-
-; or to get the side effect at the end:
-
- (reset (list "main content" 'i (list 'like (list 'the (damn3) 'boy))))
- ; '(("main content" i (like (the id boy))) ("side effect" bad))