Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!mit-amt!sokolov From: sokolov@mit-amt (Michael Sokolov) Newsgroups: comp.lang.lisp Subject: Redefining read-eval-print loop. Message-ID: <3185@mit-amt> Date: 19 Oct 88 20:49:32 GMT Reply-To: sokolov@media-lab.media.mit.edu (Michael Sokolov) Organization: MIT Media Lab, Cambridge MA Lines: 29 In article <589@dcl-csvax.comp.lancs.ac.uk> simon@comp.lancs.ac.uk (Simon Brooke) writes: > And if we aren't allowed to redefine the way the top-level read - eval >- print loop works, then the language certainly isn't as expressive: there is >a large category of things it can't express. It is still possible to redefine the way the read-eval-print loop works; you just have to wrap your own read-eval-print loop around the lisp's, making sure to include an unwind-protect so that your loop won't get aborted out of. The only tricky thing is that you may have to write an s-expression parser to do this just right, but without the niceties: (defun repl () (tagbody spot (format t "~%~A" *prompt*) (let (val) (unwind-protect (loop (setq val (eval (read))) (format t "~S" val) (format t "~%~A" *prompt*)) (go spot))))) You can replace the call to eval in this function with a call to your favorite evaluator! Once you evaluate "(repl)" it never returns. MS