Skip to content

Instantly share code, notes, and snippets.

@lojikil
Created March 12, 2012 16:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lojikil/2023163 to your computer and use it in GitHub Desktop.
Save lojikil/2023163 to your computer and use it in GitHub Desktop.
Hydra's load procedure
(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)))))
@lojikil
Copy link
Author

lojikil commented Mar 12, 2012

Shadowing 'f like that is ugly...

@lojikil
Copy link
Author

lojikil commented Mar 12, 2012

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 opened, 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