Add macro to simplify task context references
This commit is contained in:
parent
b4cdfc341a
commit
5360e73d60
4 changed files with 54 additions and 44 deletions
|
@ -11,7 +11,8 @@
|
|||
get-context-triggers
|
||||
context-triggered?
|
||||
register-context-var!
|
||||
context-ref))
|
||||
context-ref
|
||||
bind-context-vars))
|
||||
|
||||
(define-record-type <context>
|
||||
(make-context connection vars scratch-dir)
|
||||
|
@ -37,3 +38,10 @@
|
|||
|
||||
(define (register-context-var! ctx var-name val)
|
||||
(set-context-vars! ctx (assoc-set! (context-vars ctx) var-name val)))
|
||||
|
||||
(define-syntax bind-context-vars
|
||||
(syntax-rules ()
|
||||
((bind-context-vars (var-name ...) proc)
|
||||
(lambda (ctx)
|
||||
(let ((var-name (context-ref ctx (quote var-name))) ...)
|
||||
(proc ctx))))))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue