From b007b8801197325f3bd157c383bdfcace0ff57fc Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Thu, 15 Oct 2009 02:34:21 +0200 Subject: 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. --- scheme/plt/geiser/eval.ss | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'scheme/plt/geiser/eval.ss') 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) -- cgit v1.2.3