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



Nathan Baum wrote:
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?

So HANDLER-CASE unwinds the dynamic environments before executing its forms. Most unexpected. It works if I use HANDLER-BIND.


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

I think that's a bit ugly, though. Is there a common idiom for what I want to do, or should I go ahead and roll my own macro?
.




Relevant Pages