diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-10-15 02:34:21 +0200 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2009-10-15 02:34:21 +0200 |
commit | b007b8801197325f3bd157c383bdfcace0ff57fc (patch) | |
tree | 11f183ece13c67111cac6b8716ed905e4569c193 /scheme/plt/geiser/eval.ss | |
parent | d56dfe6f1505b99f90a4978dffd0b592fef72a68 (diff) | |
download | geiser-guile-b007b8801197325f3bd157c383bdfcace0ff57fc.tar.gz geiser-guile-b007b8801197325f3bd157c383bdfcace0ff57fc.tar.bz2 |
PLT: Evaluation takes into account #lang forms.
This is useful when visiting a file that has not been loaded: the
evaluation namespace is provided by its #lang, if any.
While i was at it, i also refactored the mess in geiser:load-file.
Diffstat (limited to 'scheme/plt/geiser/eval.ss')
-rw-r--r-- | scheme/plt/geiser/eval.ss | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/scheme/plt/geiser/eval.ss b/scheme/plt/geiser/eval.ss index 86b10cd..d432daa 100644 --- a/scheme/plt/geiser/eval.ss +++ b/scheme/plt/geiser/eval.ss @@ -41,27 +41,28 @@ (define (set-last-result . vs) (set! last-result `((result ,@(map write-value vs))))) -(define (eval-in form spec) +(define (call-with-result thunk) (set-last-result (void)) (let ((output (with-output-to-string (lambda () (with-handlers ((exn? set-last-error)) - (update-module-cache spec form) - (call-with-values - (lambda () (eval form (module-spec->namespace spec))) - set-last-result)))))) + (call-with-values thunk set-last-result)))))) (append last-result `((output . ,output))))) +(define (eval-in form spec lang) + (call-with-result + (lambda () + (update-module-cache spec form) + (eval form (module-spec->namespace spec lang))))) + (define compile-in eval-in) (define (load-file file) - (let ((current-path (namespace->module-path-name (last-namespace))) - (result (eval-in `(load-module ,file (current-output-port)) - 'geiser/eval))) - (update-module-cache file) - (load-module (and (path? current-path) (path->string current-path))) - result)) + (call-with-result + (lambda () + (load-module file (current-output-port) (last-namespace)) + (update-module-cache file)))) (define compile-file load-file) |