add kw support to make-caching-proc

dev-0.1
Matthew Butterick 9 years ago
parent e613f0cade
commit aaf3d8fe53

@ -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)

Loading…
Cancel
Save