This is written for Guile and works (it seems) on version 1.6.7. I'd like to know how it can be rewritten to get rid of the calls to primitive-eval, which, according to the documentation, evaluates the expression in the top-level environment specified by the current module.
(define (load-all-modified . files) ; Load each of the given files if it's been modified since it was last loaded. (map (lambda (f) (load-if-modified f)) files)) (define (load-if-modified fname) ; Load the contents of the file with the given name if the file hasn't been ; loaded before or if the file has been modified after being loaded; otherwise ; do nothing. (let ((fp (%search-load-path fname))) (if (not fp) (error (string-append "Can't find the file " fname " in %load-path, or it's unreadable.")) (let ((sym (string->symbol (string-append fname ":mtime"))) (mtime (stat:mtime (stat fp)))) (if (and (defined? sym) (apply <= (list mtime (primitive-eval sym)))) (display (string-append fname " unmodified, nothing done.")) (begin (primitive-eval (list 'define sym mtime)) (load-from-path fname) (display (string-append "Modified file " fname " loaded.")))) (newline)))))