home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!mips!sdd.hp.com!uakari.primate.wisc.edu!ames!agate!apple!cambridge.apple.com!bill@cambridge.apple.com
- From: bill@cambridge.apple.com (Bill St. Clair)
- Newsgroups: comp.lang.lisp.mcl
- Subject: Re: toplevel-loop example
- Message-ID: <9207311554.AA20428@cambridge.apple.com>
- Date: 31 Jul 92 17:36:26 GMT
- Sender: info-mcl-request@cambridge.apple.com
- Lines: 46
- Approved: comp.lang.lisp.mcl@Cambridge.Apple.C0M
- Full-Name: Bill St. Clair
- Original-To: djskrien@COLBY.EDU (Dale Skrien)
- Original-Cc: info-mcl
-
- >On page 654 in the MCL 2.0 final manual, I am told that you want your
- >toplevel function to catch aborts if you don't want the listener to appear
- >with an error message. Then the manual gives an example that shows what
- >goes wrong if you don't catch aborts:
- >? (defun new-top (&aux form)
- > (setq form (read))
- > (if (eq form 'done)
- > (%set-toplevel #'toplevel-loop)
- > (print (eval form))))
- >? (%set-toplevel #'new-top)
- >? (toplevel)
- >At this point, if you type a command-period, you are supposed to get an
- >error
- >message saying that it can't throw to tag :abort.
- >
- >However, when I tried this, and typed a command-period, nothing happened.
- >The new-top function just ignored the command-period. Is the manual
- >correct? If so, why didn't I get the error message?
-
- The manual is incorrect. There is an abort handler that is always active
- that throws to a catch in the kernel which calls the toplevel function.
- No error message.
-
- >Can someone give me a simple modification of the above example that catches
- >aborts, brings up a message dialog with an error message, and then returns
- >to the top-level function?
-
- Time to re-read the Conditions chapter of CLtL2?
-
- (defun new-top ()
- (restart-case
- (new-top-internal)
- (abort ()
- :report (lambda (stream)
- (format stream
- "Pop up message dialog then return to toplevel."))
- (message-dialog "Top-level loop aborted"))))
-
- (defun new-top-internal (&aux form)
- (setq form (read))
- (if (eq form 'done)
- (%set-toplevel #'toplevel-loop)
- (print (eval form))))
-
- (%set-toplevel #'new-top)
- (toplevel)
-