Programming Languages (CS302 2007S)
[Skip to Body]
Admin:
[Front Door]
[Glance]
[Handouts]
[Honesty]
Current:
[Current Outline]
[Current EBoard]
[Current Homework]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Outlines]
[Readings]
[Reference]
[HOG]
Misc:
[SamR]
[CSC302 1999S]
[CSC302 2006S]
Back to Implementing LISP. On to Continuations and Web Servers.
This outline is also available in PDF.
Held: Wednesday, February 28, 2007
Summary: Today we begin to explore continuations, one of the more interesting control mechanisms in Scheme.
Related Pages:
Notes:
Overview:
the state of the programor
what happens next
(+ 4 (* 3 (- (+ x x) a)))
(* ...)
is add 4"or
(lambda (x) (+ x 4))
(- ...)
is multiply by 3 and then add 4, or
(lambda (x) (+ 4 (* 3 x)))
(+ x x)
is ...
the next code to execute
(call-with-current-continuation (lambda (cont) ...))
(call/cc (lambda (cont) ...))
is an alias for
call-with-current-continaution
.
(let/cc k body)
(call/cc (lambda (k) body))
(+ 3 (* 4 (- (/2 x) 5)))
exit
, which lets you return to the top level
resume
, which lets you restart the code at the
stopped point.
resume
and then call
exit
.
exit
resumes the other routine.
(define cps-plus (lambda (x y cont) (cont (+ x y))))
(+ 4 (* 3 (- (+ x x) a)))
(cps-plus x x (lambda (tmp1) (cps-minus tmp1 a (lambda (tmp2) (cps-times 3 tmp2 (lambda (tmp3) (cps-plus 4 tmp3 (lambda (tmp4) (display-result tmp4)
Back to Implementing LISP. On to Continuations and Web Servers.
[Skip to Body]
Admin:
[Front Door]
[Glance]
[Handouts]
[Honesty]
Current:
[Current Outline]
[Current EBoard]
[Current Homework]
Groupings:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Outlines]
[Readings]
[Reference]
[HOG]
Misc:
[SamR]
[CSC302 1999S]
[CSC302 2006S]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Sun Apr 29 11:26:14 2007.
The source to the document was last modified on Tue Jan 16 13:34:43 2007.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS302/2007S/Outlines/outline.17.html
.
You may wish to validate this document's HTML ; ; Check with Bobby
Samuel A. Rebelsky, rebelsky@grinnell.edu