Load now takes an optional second argument, which must be a

procedure that would be applied to every expression in the file.
The default value for this procedure is eval.
This commit is contained in:
Abdulaziz Ghuloum 2006-12-02 10:57:50 -05:00
parent e32a8cc972
commit aac9071f2a
2 changed files with 15 additions and 11 deletions

Binary file not shown.

View File

@ -672,21 +672,25 @@
x)))
(let ()
(define read-and-eval
(lambda (p)
(lambda (p eval)
(let ([x (read p)])
(unless (eof-object? x)
(eval x)
(read-and-eval p)))))
(read-and-eval p eval)))))
(primitive-set! 'load
(lambda (x)
(unless (string? x)
(error 'load "~s is not a string" x))
(let ([p (open-input-file x)])
(let ([x (read-initial p)])
(unless (eof-object? x)
(eval x)
(read-and-eval p)))
(close-input-port p)))))
(case-lambda
[(x) (load x eval)]
[(x eval)
(unless (string? x)
(error 'load "~s is not a string" x))
(unless (procedure? eval)
(error 'load "~s is not a procedure" eval))
(let ([p (open-input-file x)])
(let ([x (read-initial p)])
(unless (eof-object? x)
(eval x)
(read-and-eval p eval)))
(close-input-port p))])))
)