Created
March 12, 2012 16:26
-
-
Save lojikil/2023163 to your computer and use it in GitHub Desktop.
Hydra's load procedure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (hydra@load src-file) | |
"an implementation of the primitive procedure load" | |
(with f (open src-file :read) | |
(with-exception-handler | |
(fn (x) (display (format "An error occured while loading ~S: ~a\n" src-file x)) (close f)) | |
(fn () | |
(letrec ((loop (fn (expr) | |
(if (eq? expr #e) | |
#v | |
(begin | |
;; (hydra@vm (list->vector (hydra@eval expr *tlenv*)) *tlenv*) | |
;; has become: | |
;; (hydra@eval expr *tlenv*) | |
;; the end user doesn't really care about the intricacies of | |
;; the VM or the compiler, so the old hydra@eval has become | |
;; hydra@compile, and the new hydra@eval is just a shell around | |
;; these two. | |
(hydra@vm (list->vector (hydra@eval expr *tlenv*)) *tlenv*) | |
(loop (read f))))))) | |
(loop (read f))) | |
(close f))))) |
Also, it was wrong: either there should have been a call to port-filename
to get back the filename associated with the port that I open
ed, or it should have used another binding (which is what I did here).
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Shadowing 'f like that is ugly...