首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >sbcl: in宏中的sbcl样式-警告

sbcl: in宏中的sbcl样式-警告
EN

Stack Overflow用户
提问于 2017-10-09 22:45:16
回答 1查看 289关注 0票数 2

在sbcl中,我知道我可以在使用&可选的和&key的defun时屏蔽预期的消息,但这在Def宏中似乎不起作用。(我知道,我应该重新设计/重写,但这是遗留代码。)

当我编译这个文件时..。

代码语言:javascript
复制
(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)))

..。这种情况会发生:

代码语言:javascript
复制
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$ 

我该如何抑制这些诊断?

编辑1:

由于这是遗留代码,我只需要为sbcl准备就绪而对其进行按摩,然后将其置之不理,所以我没有理由不能在任何使用它的代码中执行这样的操作:

代码语言:javascript
复制
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$ 

但是有什么东西可以抑制宏定义中的样式警告吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-10-10 01:54:24

你得跑

代码语言:javascript
复制
(declaim (sb-ext:muffle-conditions style-warning))

在编译表单(defmacro betty ...)之前。

其中一种方法就是

代码语言:javascript
复制
$ 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

其中5.lisp文件只包含wilmabetty

代码语言:javascript
复制
(defun wilma (&optional wilma1 &key wilma2 wilma3)
  (declare (ignore wilma1 wilma2 wilma3)))

(defmacro betty (&optional betty1 &key betty2 betty3)
  (declare (ignore betty1 betty2 betty3)))
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46656090

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档