Commit 39047c3e authored by hayeah via gmail com's avatar hayeah via gmail com

A little more details for example.lisp

parent 88189ad0
......@@ -13,7 +13,8 @@
(deform stack-calculator (stack transcript)
;; The fields of the form.
(+ - * / push new-number)
;; The following form is evaluated and the value(s) returned to the caller.
;; When user submit the form, the following expression is evaluated
;; and the value(s) returned to the caller's continuation.
(let ((op (^symbol (find-if-not #'null (list + - * / push)))))
(if push
(list op (cons (parse-integer new-number) stack))
......@@ -23,6 +24,7 @@
(:input :name push :type 'submit :value 'push) (:br)
(:input :name + :type 'submit :value '+)
(:input :name - :type 'submit
;; Ignore this comment. I have it here to remind myself.
;; '- doesn't output anything because dash is used for the conversion
;; `foo-bar' => `fooBar'.
:value "-")
......@@ -53,7 +55,12 @@
(defwethod calculator-loop ()
with transcript
for (op stack) =
for (op stack) =
;; `read-form' will output the html for the form, save the continuation,
;; and return immediately from `calculator-loop'. When the user submits the
;; form, the url-handler calls the continuation.
;; To the programmer, it appears as though read-form returns (list op stack).
(read-form 'stack-calculator nil nil) then (read-form 'stack-calculator stack transcript)
do (if (eql op 'push)
(push (list 'push (car stack)) transcript)
......@@ -111,10 +118,12 @@
;; What follows is a transcript of what happens behind the scene.
;; note that the continuation number is 9. ("/wisp-sys/form-k/9")
;; corresponding to ("form-k/:k-id" :handler call-form-k)
<form action='/wisp-sys/form-k/9' method='post'>
<input name='(stack-calculator new-number)'>
......@@ -132,6 +141,8 @@
(let ((*parameters* `(("(stack-calculator push)" . "push")
("(stack-calculator new-number)" . "10"))))
(call-form-k "9"))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment