| Paste number 18280: | A REPL |
| Pasted by: | pjb |
| When: | 7 years, 2 months ago |
| Share: | Tweet this! | http://paste.lisp.org/+E3S |
| Channel: | #lisp |
| Paste contents: |
(defmacro handling-errors (&body body)
`(HANDLER-CASE (progn ,@body)
(simple-condition
(ERR)
(format *error-output* "~&~A: ~%" (class-name (class-of err)))
(apply (function format) *error-output*
(simple-condition-format-control err)
(simple-condition-format-arguments err))
(format *error-output* "~&"))
(condition
(ERR)
(format *error-output* "~&~A: ~% ~S~%"
(class-name (class-of err)) err))))
(defun repl ()
(do ((+eof+ (gensym))
(hist 1 (1+ hist)))
(nil)
(format t "~%~A[~D]> " (package-name *package*) hist)
(handling-errors
(setf +++ ++ ++ + + - - (read *standard-input* nil +eof+))
(when (or (eq - +eof+)
(member - '((quit)(exit)(continue)) :test (function equal)))
(return-from repl))
(setf /// // // / / (multiple-value-list (eval -)))
(setf *** ** ** * * (first /))
(format t "~& --> ~{~S~^ ;~% ~}~%" /))))
This paste has no annotations.