summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2016-01-12 08:36:37 -0500
committerDavid Thompson <dthompson2@worcester.edu>2016-01-12 08:38:51 -0500
commit2e7b9a36b369938bcc5a488449b9759a1f700024 (patch)
tree26814b0b417c88b3edeac5d0879e4747a8c01ed0
parent4820142ac1741e9137a832cf20f2e17f6912b5c3 (diff)
signal: Run newly added hooks immediately.
* sly/signal.scm (add-signal-hook!): Apply 'proc' immediately.
-rw-r--r--sly/signal.scm8
1 files changed, 6 insertions, 2 deletions
diff --git a/sly/signal.scm b/sly/signal.scm
index a35f042..5bd9a29 100644
--- a/sly/signal.scm
+++ b/sly/signal.scm
@@ -116,8 +116,12 @@ procedure PROC, and a list of INPUTS."
(define (add-signal-hook! signal proc)
"Add PROC, a procedure that accepts a single argument, to the hook
associated with SIGNAL. When SIGNAL receives a new value, PROC will
-be applied with that value."
- (add-hook! (signal-hook (signal-unbox signal)) proc))
+be applied with that value. PROC will automatically be called once
+after registering it to run the hook with the current value of
+SIGNAL."
+ (add-hook! (signal-hook (signal-unbox signal)) proc)
+ ;; Run the initial hook.
+ (proc (signal-ref signal)))
(define (remove-signal-hook! signal proc)
"Remove the procedure PROC from the hook associated with SIGNAL."