Guarding @import expressions from the repl.

This commit is contained in:
Alex Shinn 2013-04-01 20:38:35 +09:00
parent 4452607836
commit b840602d6c

View file

@ -195,18 +195,23 @@
(mod+imps (eval `(resolve-import ',mod-name) (mod+imps (eval `(resolve-import ',mod-name)
meta-env))) meta-env)))
(if (pair? mod+imps) (if (pair? mod+imps)
(let ((env (if (eq? op 'import-only) (guard
(let ((env (make-environment))) (exn
(interaction-environment env) (else
env) (print-exception exn (current-error-port))
env)) (fail "error loading module:" mod-name)))
(imp-env (let ((env (if (eq? op 'import-only)
(vector-ref (let ((env (make-environment)))
(eval `(load-module ',(car mod+imps)) (interaction-environment env)
meta-env) env)
1))) env))
(%import env imp-env (cdr mod+imps) #f) (imp-env
(continue module env meta-env)) (vector-ref
(eval `(load-module ',(car mod+imps))
meta-env)
1)))
(%import env imp-env (cdr mod+imps) #f)
(continue module env meta-env)))
(fail "couldn't find module:" mod-name)))) (fail "couldn't find module:" mod-name))))
((in) ((in)
(let ((name (read/ss in))) (let ((name (read/ss in)))
@ -269,20 +274,20 @@
(for-each (for-each
(lambda (expr) (lambda (expr)
(call-with-values (call-with-values
(lambda () (lambda ()
(eval (list 'begin expr) env)) (eval (list 'begin expr) env))
(lambda res-list (lambda res-list
(cond (cond
((not (or (null? res-list) ((not (or (null? res-list)
(equal? res-list (equal? res-list
(list (if #f #f))))) (list (if #f #f)))))
(write/ss (car res-list) out) (write/ss (car res-list) out)
(for-each (for-each
(lambda (res) (lambda (res)
(write-char #\space out) (write-char #\space out)
(write/ss res out)) (write/ss res out))
(cdr res-list)) (cdr res-list))
(newline out)))))) (newline out))))))
expr-list)))))) expr-list))))))
;; If an interrupt occurs while the child thread is ;; If an interrupt occurs while the child thread is
;; still running, terminate it, otherwise wait for it ;; still running, terminate it, otherwise wait for it