From 8ef593dc9802e11f3222ab81e021e8807fd8bdb9 Mon Sep 17 00:00:00 2001 From: Christopher Allan Webber Date: Tue, 17 Nov 2015 16:53:25 -0600 Subject: [PATCH] agenda now actually runs (but doesn't do anything useful...) --- loopy.scm | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/loopy.scm b/loopy.scm index 3db157d..0f6edc5 100644 --- a/loopy.scm +++ b/loopy.scm @@ -7,18 +7,20 @@ ;; replace this (define-immutable-record-type - (make-agenda queue) + (make-agenda-intern queue) agenda? (queue agenda-queue)) -(define %current-agenda - (make-parameter (make-agenda (make-q)))) +(define* (make-agenda #:key (queue (make-q))) + (make-agenda-intern queue)) + +(define %current-agenda (make-parameter #f)) (define* (start-agenda agenda #:optional stop-condition) (let loop ((agenda agenda)) (let ((new-agenda - (agenda-run-once agenda))) - (%current-agenda new-agenda) + (parameterize ((%current-agenda agenda)) + (agenda-run-once agenda)))) (if (and stop-condition (stop-condition)) 'done (loop new-agenda))))) @@ -38,11 +40,11 @@ based on the results" (match proc-result ((? procedure? new-proc) (enqueue new-proc)) - (((? procedure? new-procs) ..) + (((? procedure? new-procs) ...) (for-each (lambda (new-proc) (enqueue new-proc)) - new-procs))) - ;; TODO: Selecting on ports would happen here? - ;; Return new agenda, with next queue set - (set-field agenda (agenda-queue) next-queue))))) + new-procs))))) + ;; TODO: Selecting on ports would happen here? + ;; Return new agenda, with next queue set + (set-field agenda (agenda-queue) next-queue))) -- 2.31.1