2017-10-09 5 views
2

sbclでは、&オプションと&キーをdefunに使用すると、予想されるメッセージを消すことができますが、defmacroでは動作しないようです。 (私はちょうど私が知っている、/書き換えを再設計する必要がありますが、これはレガシーコードである)sbcl:defmacroのマフルスタイル警告

私は、このファイルをコンパイル...

(declaim (sb-ext:muffle-conditions style-warning)) 

(defun wilma (&optional wilma1 &key wilma2 wilma3) 
    (declare (ignore wilma1 wilma2 wilma3))) 

(defmacro betty (&optional betty1 &key betty2 betty3) 
    (declare (ignore betty1 betty2 betty3))) 

を...これが起こる:

home:~/sbcl/experiments/style-warning.d$ sbcl --noinform 
* (compile-file "5.lisp") 

; compiling file "/u/home/sbcl/experiments/style-warning.d/5.lisp" (written 09 OCT 2017 03:31:44 PM): 
; compiling (DECLAIM (MUFFLE-CONDITIONS STYLE-WARNING)) 
; compiling (DEFUN WILMA ...) 
; compiling (DEFMACRO BETTY ...) 
; file: /u/home/sbcl/experiments/style-warning.d/5.lisp 
; in: DEFMACRO BETTY 
;  (DEFMACRO BETTY (&OPTIONAL BETTY1 &KEY BETTY2 BETTY3) 
;  (DECLARE (IGNORE BETTY1 BETTY2 BETTY3))) 
; 
; caught STYLE-WARNING: 
; &OPTIONAL and &KEY found in the same lambda list: (&OPTIONAL BETTY1 &KEY BETTY2 
;              BETTY3) 
; 
; compilation unit finished 
; caught 1 STYLE-WARNING condition 


; /u/home/sbcl/experiments/style-warning.d/5.fasl written 
; compilation finished in 0:00:00.018 
#P"/u/home/sbcl/experiments/style-warning.d/5.fasl" 
T 
NIL 
* (exit) 
home:~/sbcl/experiments/style-warning.d$ 

どのようにこれらの診断を抑制するのですか?

EDIT 1:

これは、レガシーコードであると私はSBCL-の準備のためにそれをマッサージして、一人でそれを残しておきます、私は任意のコードするこのような何かを行うことができない理由はありませんので、

home:~/sbcl/experiments/style-warning.d$ sbcl --noinform 
* (with-open-file (*error-output* "/dev/null" :direction :output :if-exists :append) 
(compile-file "5.lisp")) 

; compiling file "/u/home/sbcl/experiments/style-warning.d/5.lisp" (written 09 OCT 2017 03:31:44 PM): 
; compiling (DECLAIM (MUFFLE-CONDITIONS STYLE-WARNING)) 
; compiling (DEFUN WILMA ...) 
; compiling (DEFMACRO BETTY ...) 

; /u/home/sbcl/experiments/style-warning.d/5.fasl written 
; compilation finished in 0:00:00.017 
#P"/u/home/sbcl/experiments/style-warning.d/5.fasl" 
T 
NIL 
* (exit) 
home:~/sbcl/experiments/style-warning.d$ 

しかし、マクロ定義でスタイル警告を抑制できるものがありますか?

答えて

4

フォーム(defmacro betty ...)がコンパイルされる前

(declaim (sb-ext:muffle-conditions style-warning)) 

を実行する必要があります。

(defun wilma (&optional wilma1 &key wilma2 wilma3) 
    (declare (ignore wilma1 wilma2 wilma3))) 

(defmacro betty (&optional betty1 &key betty2 betty3) 
    (declare (ignore betty1 betty2 betty3))) 
:それをする

一つの方法は、ファイル5.lispのみwilmabettyが含まれてい

$ sbcl --non-interactive --eval '(declaim (sb-ext:muffle-conditions style-warning))' --eval '(compile-file "5")' 
This is SBCL 1.4.0, an implementation of ANSI Common Lisp. 
More information about SBCL is available at <http://www.sbcl.org/>. 

SBCL is free software, provided as is, with absolutely no warranty. 
It is mostly in the public domain; some portions are provided under 
BSD-style licenses. See the CREDITS and COPYING files in the 
distribution for more information. 
; compiling file "/Users/sds/lisp/5.lisp" (written 09 OCT 2017 09:51:51 PM): 
; compiling (DEFUN WILMA ...) 
; compiling (DEFMACRO BETTY ...) 

; /Users/sds/lisp/5.fasl written 
; compilation finished in 0:00:00.010 

です