开发者

Common Lisp: deleting unreachable code

开发者 https://www.devze.com 2023-01-19 18:26 出处:网络
This is an easy one. (let ((x)) (if (typep x \'null) \"a\" \"b\")) generate a warning about unreachable code deletion. Presumably the compiler was smart enough to figure that it is only executed on

This is an easy one.

(let ((x))
(if (typep x 'null) "a" "b"))

generate a warning about unreachable code deletion. Presumably the compiler was smart enough to figure that it is only executed once and the type will always be null. I wouldn't normally write that code, but in this case I just don't want the code deletion notice in my o开发者_如何学Goutput. How can I shut SBCL up about that particular warning? As a note, I also haven't been able to find the right syntax to tell sbcl to set safety to 0 so that I can overflow an integer (educationally)... Perhaps related?

Thanks, Conrad


Wrap whatever compiles the code in a handler-bind with a handler for sb-ext:compiler-note that's handled with muffle-warning. See also http://www.sbcl.org/manual/#Controlling-Verbosity

SBCL has modular arithmetic, so you can get very fast arithmetic by declaring variable types and wrapping the operations in (logand mask (+ x y)), where the mask is #xFFFF or #xFFFFFFFF or whatever. See also http://www.sbcl.org/manual/#Modular-arithmetic

0

精彩评论

暂无评论...
验证码 换一张
取 消