[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/02: memoization: (mlambda () ...) allows for inner 'define'.
From: |
Ludovic Courtès |
Subject: |
01/02: memoization: (mlambda () ...) allows for inner 'define'. |
Date: |
Sun, 3 Sep 2017 17:36:23 -0400 (EDT) |
civodul pushed a commit to branch master
in repository guix.
commit e3c83a7cd3618a87d74e58973dcd82e560e2da97
Author: Ludovic Courtès <address@hidden>
Date: Sun Sep 3 23:29:11 2017 +0200
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.
---
guix/memoization.scm | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/guix/memoization.scm b/guix/memoization.scm
index 5cae283..bf3b73d 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)))