mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2025-01-31 14:56:54 +01:00
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.
This commit is contained in:
parent
4363767394
commit
e3c83a7cd3
1 changed files with 3 additions and 2 deletions
|
@ -76,10 +76,11 @@ (define-syntax %mlambda
|
|||
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)))
|
||||
|
||||
|
|
Loading…
Reference in a new issue