From dd39f5984d6f9769bc179cd6cddf670559acc570 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Thu, 24 May 2001 03:41:28 +0000 Subject: [PATCH] Change GET-MEMOIZED-RESOURCE to accept an optional argument specifying that it is an error if there is no associated resource. --- v7/src/imail/imail-core.scm | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) 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 -- 2.25.1