aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-04-09 09:52:48 +0200
committerLudovic Courtès <ludo@gnu.org>2019-04-10 12:40:58 +0200
commit95207e70d561517c8db8992f61552004f8213b04 (patch)
tree3d645941b3c13886b5f6d3d3f170e3354cea5706
parent5c32857f91b26846d202f07226f201fd49852619 (diff)
downloadpatches-95207e70d561517c8db8992f61552004f8213b04.tar
patches-95207e70d561517c8db8992f61552004f8213b04.tar.gz
store: 'with-store' expands to a single procedure call.
* guix/store.scm (call-with-store): New procedure. (with-store): Write in terms of 'call-with-store'.
-rw-r--r--guix/store.scm12
1 files changed, 8 insertions, 4 deletions
diff --git a/guix/store.scm b/guix/store.scm
index 0a0a7c7c52..fdd04f349d 100644
--- a/guix/store.scm
+++ b/guix/store.scm
@@ -602,19 +602,23 @@ connection. Use with care."
"Close the connection to SERVER."
(close (store-connection-socket server)))
-(define-syntax-rule (with-store store exp ...)
- "Bind STORE to an open connection to the store and evaluate EXPs;
-automatically close the store when the dynamic extent of EXP is left."
+(define (call-with-store proc)
+ "Call PROC with an open store connection."
(let ((store (open-connection)))
(dynamic-wind
(const #f)
(lambda ()
(parameterize ((current-store-protocol-version
(store-connection-version store)))
- exp) ...)
+ (proc store)))
(lambda ()
(false-if-exception (close-connection store))))))
+(define-syntax-rule (with-store store exp ...)
+ "Bind STORE to an open connection to the store and evaluate EXPs;
+automatically close the store when the dynamic extent of EXP is left."
+ (call-with-store (lambda (store) exp ...)))
+
(define current-store-protocol-version
;; Protocol version of the store currently used. XXX: This is a hack to
;; communicate the protocol version to the build output port. It's a hack