[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Hiding Warnings: probs w/prev code



I've been trying to muffle some warnings and I've been playing with code
that was posted to the mail list in July by (St. Clair, William):

(defmacro without-warnings (&body body)
    `(handler-bind ((warning
                     #'(lambda (condition)
                         (muffle-warning condition))))
       ,@body))
(defmacro without-compiler-warnings (&body body)
    `(handler-bind ((compiler-warning
                     #'(lambda (condition)
                         (muffle-warning condition))))
       ,@body))

In some cases this works as advertised:
? (warn "foo")
;Warning: foo
; While executing: CCL::TOPLEVEL-EVAL
NIL
? (without-warnings (warn "foo"))
NIL
? 

However, there are two problems:

1) I want to muffle UNDEFINED FUNCTION warnings in a bunch of defuns.
I can't make this work; The workaround that I'm using is awkward:
;;;;;;;;;; Doesn't work:
? (without-warnings (defun shoe () (horn)))
;Compiler warnings :
;   Undefined function HORN, in SHOE inside an anonymous lambda form.
SHOE
;;;;;;;;;; Awkward workaround:
? (without-warnings (compile 'shoe '(lambda () (horn))))
SHOE
NIL
NIL
?

2) COMPILER-WARNINGs don't really seem to be defined in my MCL2.0b1p3.
Although the author of the macros gets the following result:
? (without-compiler-warnings (compile nil '(lambda () x)))
#<Anonymous Function #xD41ED6>
NIL
NIL
?
I get the following instead:
? (without-compiler-warnings (compile nil '(lambda () x)))
> Error: COMPILER-WARNING is not a known type specifier.
> While executing: CCL::BAD-TYPESPEC
> Type Command-. to abort.
See the Restarts... menu item for further choices.
1 > 

Any insights or better workarounds would be appreciated... 

 -Lee (spector@cs.umd.edu)