aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2017-09-03 23:29:11 +0200
committerLudovic Courtès <ludo@gnu.org>2017-09-03 23:36:17 +0200
commite3c83a7cd3618a87d74e58973dcd82e560e2da97 (patch)
treec0e3aaa4db8c59eba64f045478ed08be8cfa17ab
parent43637673944226412a27967c235046546d7771ed (diff)
downloadguix-e3c83a7cd3618a87d74e58973dcd82e560e2da97.tar
guix-e3c83a7cd3618a87d74e58973dcd82e560e2da97.tar.gz
memoization: (mlambda () ...) allows for inner 'define'.
Previously (mlambda () (define foo 2) bar) would trigger a syntax error. * guix/memoization.scm (%mlambda): In the zero-argument case, move BODY... to a lambda to allow for inner 'define' and such.
-rw-r--r--guix/memoization.scm5
1 files changed, 3 insertions, 2 deletions
diff --git a/guix/memoization.scm b/guix/memoization.scm
index 5cae283610..bf3b73d806 100644
--- a/guix/memoization.scm
+++ b/guix/memoization.scm
@@ -76,10 +76,11 @@ the result is returned via (apply values results)."
exactly one value."
((_ cached () body ...)
;; The zero-argument case is equivalent to a promise.
- (let ((result #f) (cached? #f))
+ (let ((result #f) (cached? #f)
+ (compute (lambda () body ...)))
(lambda ()
(unless cached?
- (set! result (begin body ...))
+ (set! result (compute))
(set! cached? #t))
result)))