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:
parent
e32a8cc972
commit
aac9071f2a
BIN
lib/ikarus.boot
BIN
lib/ikarus.boot
Binary file not shown.
|
@ -672,21 +672,25 @@
|
||||||
x)))
|
x)))
|
||||||
(let ()
|
(let ()
|
||||||
(define read-and-eval
|
(define read-and-eval
|
||||||
(lambda (p)
|
(lambda (p eval)
|
||||||
(let ([x (read p)])
|
(let ([x (read p)])
|
||||||
(unless (eof-object? x)
|
(unless (eof-object? x)
|
||||||
(eval x)
|
(eval x)
|
||||||
(read-and-eval p)))))
|
(read-and-eval p eval)))))
|
||||||
|
|
||||||
(primitive-set! 'load
|
(primitive-set! 'load
|
||||||
(lambda (x)
|
(case-lambda
|
||||||
(unless (string? x)
|
[(x) (load x eval)]
|
||||||
(error 'load "~s is not a string" x))
|
[(x eval)
|
||||||
(let ([p (open-input-file x)])
|
(unless (string? x)
|
||||||
(let ([x (read-initial p)])
|
(error 'load "~s is not a string" x))
|
||||||
(unless (eof-object? x)
|
(unless (procedure? eval)
|
||||||
(eval x)
|
(error 'load "~s is not a procedure" eval))
|
||||||
(read-and-eval p)))
|
(let ([p (open-input-file x)])
|
||||||
(close-input-port p)))))
|
(let ([x (read-initial p)])
|
||||||
|
(unless (eof-object? x)
|
||||||
|
(eval x)
|
||||||
|
(read-and-eval p eval)))
|
||||||
|
(close-input-port p))])))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue