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



Edi Weitz wrote:
On Mon, 29 Aug 2005 23:13:44 +0100, Nathan Baum <nathan_baum@xxxxxxxxxxxxxx> wrote:


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


Why unexpected?  That exactly is the difference between HANDLER-CASE
and HANDLER-BIND.

But I didn't expect that to be the difference. ;)

Now I know.

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

I think that's a bit ugly, though.


I don't think that's ugly.

That's fine. You don't have to agree with me. :)

You can replace the lambda form with #'MUFFLE-WARNING, though.

In this instance, yes. My real code isn't only muffling the warning; it's displaying it in a nice way first. I just want to stop the implementation-defined warning output being produced (but of course I don't want to prevent further processing where the warning was signalled).


I'll some kind of macro, perhaps like

  (warning-case
     (do-something)
    (missing-function (c)
      (format t "WARNING: Function ~A not found"
              (missing-function-function c))))

if it turns out I need to do this again.


Cheers, Edi.

.