repl: Use exception handling.

* module/mes/repl.mes (repl): Use catch to prevent exit upon error.
This commit is contained in:
Jan Nieuwenhuizen 2016-12-28 20:49:19 +01:00
parent cb1fa49767
commit 1f9476aeca

View file

@ -159,6 +159,8 @@ along with Mes. If not, see <http://www.gnu.org/licenses/>.
(force-output) (force-output)
(let ((sexp (read-env a))) (let ((sexp (read-env a)))
(when (not (eq? sexp '())) (when (not (eq? sexp '()))
(catch #t
(lambda ()
(when print-sexp? (when print-sexp?
(display "[sexp=") (display "[sexp=")
(display sexp) (display sexp)
@ -170,7 +172,8 @@ along with Mes. If not, see <http://www.gnu.org/licenses/>.
(loop a)))) (loop a))))
((and (pair? sexp) (eq? (car sexp) 'mes-use-module)) ((and (pair? sexp) (eq? (car sexp) 'mes-use-module))
(loop (mes-load-module-env (cadr sexp) a))) (loop (mes-load-module-env (cadr sexp) a)))
(else (let ((e (eval sexp a))) (else
(let ((e (eval sexp a)))
(if (eq? e *unspecified*) (loop a) (if (eq? e *unspecified*) (loop a)
(let ((id (string->symbol (string-append "$" (number->string count))))) (let ((id (string->symbol (string-append "$" (number->string count)))))
(set! count (+ count 1)) (set! count (+ count 1))
@ -178,4 +181,7 @@ along with Mes. If not, see <http://www.gnu.org/licenses/>.
(display " = ") (display " = ")
(display e) (display e)
(newline) (newline)
(loop (acons id e a)))))))))))) (loop (acons id e a))))))))
(lambda (key . args)
(format (current-error-port) "exception: ~a ~a\n" key args)
(loop a))))))))