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

Hiding warnings



   From: CXEA000 <CXEA@MCGILLA.BITNET>
   Message-Id: <11JUL91.13584951.0074.MUSIC@MUSICA.MCGILL.CA>
   To: <info-macl@cambridge.apple.com>
   Subject: Hiding warnings
 
   Is there any way to turn of those anonying warning messages?
   I am trying to tranfer some code which normally runs on CLOS on the
   Unix system to MCL and it gives these warning messages. I want to shut
   these messages off until I get time to fix the code.  Any help will
   be appreciated.
 
   ------------------
   In MACL 1.x you can just set *warn-if-redefine* to nil to stop
   redefinition warnings and *compiler-warnings* to nil if you want
   to stop compiler warnings. (pg. 246 of the 1.3.2 manual)
 
 
2.0 no longer has *compiler-warnings*, but you can do it yourself with the
condition system.  To block all warnings:
 
? (defmacro without-warnings (&body body)
    `(handler-bind ((warning
                     #'(lambda (condition)
                         (muffle-warning condition))))
       ,@body))
WITHOUT-WARNINGS
? (warn "foo")
;Warning: foo
; While executing: TOPLEVEL-EVAL
NIL
? (without-warnings (warn "foo"))
NIL
 
To block just compiler warnings:
 
? (defmacro without-compiler-warnings (&body body)
    `(handler-bind ((compiler-warning
                     #'(lambda (condition)
                         (muffle-warning condition))))
       ,@body))
WITHOUT-COMPILER-WARNINGS
? (compile nil '(lambda () x))
;Compiler warnings :
;   Undeclared free variable X, in an anonymous lambda form.
#<Anonymous Function #xD40EFE>
T
T
? (without-compiler-warnings (compile nil '(lambda () x)))
#<Anonymous Function #xD41ED6>
NIL
NIL
?