summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2009-06-02 22:39:30 +0200
committerAndy Wingo <wingo@pobox.com>2009-06-03 22:20:55 +0200
commit727c259ac5c9a5415a0dac2ddbbc74193906caeb (patch)
tree3dc80c5659288c554b55631570214bcbb7a57e0e
parentd1e47c6e6c9698cd8623d370db0056176aa42bd9 (diff)
downloadguile-727c259ac5c9a5415a0dac2ddbbc74193906caeb.tar.gz
file-exists? doesn't cause a throw, simpler try-module-autoload
* module/ice-9/boot-9.scm (file-exists?): Change to use the stat interface that doesn't throw exceptions. (try-module-autoload): Simplify to take advantage of the fact that primitive-load-path does the right thing with regards to loading compiled files if they are available.
-rw-r--r--module/ice-9/boot-9.scm23
1 files changed, 5 insertions, 18 deletions
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 44066312a..5f365b484 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -611,12 +611,10 @@
(primitive-load-path "ice-9/networking"))
;; For reference, Emacs file-exists-p uses stat in this same way.
-;; ENHANCE-ME: Catching an exception from stat is a bit wasteful, do this in
-;; C where all that's needed is to inspect the return from stat().
(define file-exists?
(if (provided? 'posix)
(lambda (str)
- (->bool (false-if-exception (stat str))))
+ (->bool (stat str #f)))
(lambda (str)
(let ((port (catch 'system-error (lambda () (open-file str OPEN_READ))
(lambda args #f))))
@@ -2278,21 +2276,10 @@ module '(ice-9 q) '(make-q q-length))}."
(dynamic-wind
(lambda () (autoload-in-progress! dir-hint name))
(lambda ()
- (let ((file (in-vicinity dir-hint name)))
- (let ((compiled (and load-compiled
- (%search-load-path
- (string-append file ".go"))))
- (source (%search-load-path file)))
- (cond ((and source
- (or (not compiled)
- (< (stat:mtime (stat compiled))
- (stat:mtime (stat source)))))
- (if compiled
- (warn "source file" source "newer than" compiled))
- (with-fluid* current-reader #f
- (lambda () (load-file primitive-load source))))
- (compiled
- (load-file load-compiled compiled))))))
+ (with-fluid* current-reader #f
+ (lambda ()
+ (load-file primitive-load-path
+ (in-vicinity dir-hint name)))))
(lambda () (set-autoloaded! dir-hint name didit)))
didit))))