Commits

Moritz Heidkamp committed d1eff74

Cooler plan-let

  • Participants
  • Parent commits 1231a84

Comments (0)

Files changed (2)

File plan-impl.scm

     (make-plan (persist-map! steps))))
 
 (define-syntax plan-let
-  @("A form for realizing plans and binding the results to local variables."
+  @("A form for declaring a plan which will be realized on evaluation, binding each step to local variables."
     (@to "value of last body expression")
     (@no-source))
   (syntax-rules ()
-    ((_ (((step ...) plan) ...) body ...)
-     (match-let
-         ((((step ...) ...) (list (realize-plan plan '(step ...)) ...)))
+    ((_ ((step def ...) ...) body ...)
+     (match-let (((step ...) (realize-plan (plan (step def ...) ...) '(step ...))))
        body ...))))
 
 (define (write-plan-dot plan #!optional (out (current-output-port)) (name "plan"))

File tests/run.scm

 
 (test-group "plan-let"
   (plan-let
-   (((foo) (plan (foo (bar qux) (* bar qux))
-                 (bar 10)
-                 (qux 99)))
-    ((bar) (plan (bar 10))))
-   (test foo 990)))
+   ((foo (bar qux) (* bar qux))
+    (bar (baz) (+ baz baz))
+    (baz 5)
+    (qux 99))
+   (test foo 990)
+   (test bar 10)
+   (test baz 5)
+   (test qux 99)))
 
 (test-group "parallel realization"
   (define p