From: Chris Hanson Date: Thu, 24 May 2001 03:41:28 +0000 (+0000) Subject: Change GET-MEMOIZED-RESOURCE to accept an optional argument specifying X-Git-Tag: 20090517-FFI~2793 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=dd39f5984d6f9769bc179cd6cddf670559acc570;p=mit-scheme.git Change GET-MEMOIZED-RESOURCE to accept an optional argument specifying that it is an error if there is no associated resource. --- diff --git a/v7/src/imail/imail-core.scm b/v7/src/imail/imail-core.scm index ca929ccd4..b981f13b4 100644 --- a/v7/src/imail/imail-core.scm +++ b/v7/src/imail/imail-core.scm @@ -1,6 +1,6 @@ ;;; -*-Scheme-*- ;;; -;;; $Id: imail-core.scm,v 1.133 2001/05/24 01:19:47 cph Exp $ +;;; $Id: imail-core.scm,v 1.134 2001/05/24 03:41:28 cph Exp $ ;;; ;;; Copyright (c) 1999-2001 Massachusetts Institute of Technology ;;; @@ -358,17 +358,20 @@ (if (not (container? container)) (error:wrong-type-argument container "IMAIL container" procedure))) -(define (get-memoized-resource url) - (let ((resource (hash-table/get memoized-resources url #f))) - (and resource - (let ((resource (weak-car resource))) - ;; Delete memoization _only_ if URL-EXISTS? unambiguously - ;; states non-existence. An error is often transitory. - (if (and resource (ignore-errors (lambda () (url-exists? url)))) - resource - (begin - (hash-table/remove! memoized-resources url) - #f)))))) +(define (get-memoized-resource url #!optional error?) + (or (let ((resource (hash-table/get memoized-resources url #f))) + (and resource + (let ((resource (weak-car resource))) + ;; Delete memoization _only_ if URL-EXISTS? + ;; unambiguously states non-existence. An error is + ;; often transitory. + (if (and resource (ignore-errors (lambda () (url-exists? url)))) + resource + (begin + (hash-table/remove! memoized-resources url) + #f))))) + (and (if (default-object? error?) #f error?) + (error "URL has no associated resource:" url)))) (define (memoize-resource resource close) (hash-table/put! memoized-resources