Last active
November 20, 2016 15:32
-
-
Save zhouqiang-cl/b0dee58d1922cc93c43b125ab2bb432b to your computer and use it in GitHub Desktop.
类型声明和宏 DECLAIM 和符号 DECLARE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
语法 | |
declaim declaration-specifier* => implementation-dependent | |
declare declaration-specifier* | |
参数和值 | |
declaration-specifier --- 一个类型声明, 不对它求值 | |
描述 | |
1. common lisp 通过显式类型声明来生成高效的代码. 在 Common Lisp 中. 类型声明完全是可选的. 它们可以让程序运行的更快,但(除非错误)不会改变程序的行为 | |
2. 全局声明以 declaim 伴随一个或多个声明的形式来实现 | |
3. 局部声明通过 declare 完成,它接受的参数和 declaim 的一样 | |
代码 | |
* (declaim (inline a)) | |
(A) | |
* (defun poly (a b x) | |
(declare (fixnum a b x)) | |
(the fixnum (+ (the fixnum (* a (the fixnum (expt x 2)))) | |
(the fixnum (* b x))))) | |
POLY | |
TODO | |
为何 DECLAIM 是宏而 DECLARE 是符号 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment