scratch - char-continuation functions

This commit is contained in:
erana 2012-01-23 14:45:40 +09:00
parent 2937f43b3f
commit 54f0d2145a
4 changed files with 10 additions and 12 deletions

View File

@ -1,6 +1,6 @@
(define-interface scratch-interface (define-interface scratch-interface
(export (export
run-daemon-child-http)) char-continue))
(define-structure thttpd (define-structure thttpd
scratch-interface scratch-interface

View File

@ -1,4 +1,4 @@
(define-package "thttpd" (define-package "scratch"
(0 1) (0 1)
((install-lib-version (1 3 0))) ((install-lib-version (1 3 0)))
(write-to-load-script (write-to-load-script
@ -8,5 +8,4 @@
(install-file "README" 'doc) (install-file "README" 'doc)
(install-file "NEWS" 'doc) (install-file "NEWS" 'doc)
(install-string (COPYING) "COPYING" 'doc) (install-string (COPYING) "COPYING" 'doc)
(install-file "packages.scm" 'scheme) (install-file "scratch.scm" 'scheme))
(install-file "tserver.scm" 'scheme))

View File

@ -26,20 +26,19 @@
;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF ;;; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
;;; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;;; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
(define (get-response-f lst) (define (char-continue lst)
(define (get return) (define (get-char return)
(for-each (for-each
(lambda (element) (lambda (element)
(set! return (call-with-current-continutation (set! return (call-with-current-continutation
(lambda (r) (lambda (r)
(set! get r) (set! get-char r)
(return element))))) (return element)))))
lst) lst)
(return 'end-generate)) (return 'end-generate))
(define (gen) (define (gen)
(call-with-current-continuation get)) (call-with-current-continuation get-char))
gen) gen)
;; test
(define (get-response l) ;; (char-continue l) generates the chars with each call
(get-response-f l))

View File

@ -59,7 +59,7 @@
(call-with-current-continuation get)) (call-with-current-continuation get))
gen) gen)
(define (get-response l) (define (get-response l) ;; make l public and generate without args
(get-response-f l)) (get-response-f l))
(define (run-daemon-child-http rec) (define (run-daemon-child-http rec)