|
|
@ -4,8 +4,9 @@
|
|
|
|
(define+provide+safe (make-caching-proc base-proc)
|
|
|
|
(define+provide+safe (make-caching-proc base-proc)
|
|
|
|
(procedure? . -> . procedure?)
|
|
|
|
(procedure? . -> . procedure?)
|
|
|
|
(let ([cache (make-hash)])
|
|
|
|
(let ([cache (make-hash)])
|
|
|
|
(λ args
|
|
|
|
(make-keyword-procedure
|
|
|
|
(hash-ref! cache args (λ () (apply base-proc args))))))
|
|
|
|
(λ (kws kw-args . args)
|
|
|
|
|
|
|
|
(hash-ref! cache args (λ () (keyword-apply base-proc kws kw-args args)))))))
|
|
|
|
|
|
|
|
|
|
|
|
(provide+safe define/caching)
|
|
|
|
(provide+safe define/caching)
|
|
|
|
(define-syntax (define/caching stx)
|
|
|
|
(define-syntax (define/caching stx)
|
|
|
|