summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-08-25 19:28:44 -0400
committerDavid Thompson <dthompson2@worcester.edu>2014-08-25 19:30:25 -0400
commit5361a105fdcb097def20caa980b1956973810b94 (patch)
tree592e3360e287da6a759534c148f5ae8288b46f88
parent9162ea9ab57e48cfb32216d5b8910252f036457d (diff)
Add signal-let and signal-let* forms.
* sly/signal.scm (signal-let, signal-let*): New macros.
-rw-r--r--sly/signal.scm12
1 files changed, 12 insertions, 0 deletions
diff --git a/sly/signal.scm b/sly/signal.scm
index 41dddf2..a3e79c4 100644
--- a/sly/signal.scm
+++ b/sly/signal.scm
@@ -29,6 +29,7 @@
#:export (signal?
make-signal
define-signal
+ signal-let signal-let*
hook->signal
signal-ref
signal-ref-maybe
@@ -167,6 +168,17 @@ be coerced into one."
((_ name value)
#'(define name (make-signal-maybe value))))))
+(define-syntax-rule (signal-let ((var signal) ...) body ...)
+ ((lambda (var ...) body ...) (signal-ref signal) ...))
+
+(define-syntax signal-let*
+ (syntax-rules ()
+ ((_ ((var signal)) body ...)
+ (signal-let ((var signal)) body ...))
+ ((_ ((var signal) . rest) body ...)
+ (signal-let ((var signal))
+ (signal-let* rest body ...)))))
+
;;;
;;; Higher Order Signals
;;;