Re: (warn) isn't doing what I expect it to



+ Nathan Baum <nathan_baum@xxxxxxxxxxxxxx>:

| I'm expecting
|
| (handler-case
| (warn "foo")
| (warning (c) (muffle-warning c)))
|
| to produce no output, successfully. Instead it produces
|
| *** - INVOKE-RESTART: No restart named MUFFLE-WARNING is visible.
|
| CLHS says WARN establishes a MUFFLE-WARNING restart. What am I doing wrong?

You are using HANDLER-CASE, which unwinds the stack, thereby
discarding the restart, before invoing the handler.

You need to use HANDLER-BIND instead:

(handler-bind
((warning #'muffle-warning))
(warn "foo"))

--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- Debating gives most of us much more psychological satisfaction
than thinking does: but it deprives us of whatever chance there is
of getting closer to the truth. -- C.P. Snow
.



Relevant Pages