- 它通常用于那些你预期其值会频繁改变的变量,比如配置参数。- 语法如下:```lisp (defparameter *va...
>(decf x7) ;; ==> 2 (equivalent to (setq x (- x 7)) >(decf x) ;;==> 1 (equivalent to (setq x (1- x)) setfandsetq SETF is a macro which uses SETQ internally, but has more possibilities. In a way it's a more general assignment operator. E.g. with SETF you can do:...
而看似局部变量的信息又在函数之外的函数中发挥了作用。这种功能,或许是lisp灵活度高的很大原因,但是的确是有点让人摸不到头脑。
传入一个符号和一个值,来创造一个全局变量: CL-USER> (defparameter *glob* 99) *GLOB* CL-USER> (let ((*print-base* 16)) (princ 32)) 20 32 像这样的变量在任何地方都可以存取,除了在有定义了相同名字的局部变量的表达式里。为了避免这样情形发生,通常我们在给全局变量命名时,以星号作开始与结束。...
ANSI Common Lisp 5 Data and Control Flow 5.3 Dictionary of Data and Control Flow 5.3.16 defparameter, defvar MacroSyntax:defparameter name initial-value [documentation] name defvar name [initial-value [documentation]] name Arguments and Values:...
297_common lisp defvar defparameter defconstant使用 完整的emacs and lisp的学习集合整理如下: https://github.com/GreyZhang/g_lisp 继续common lisp的学习,这一次来对比一下三种常用的全局变量的引入方式。 定义如上变量。其中,前面两个创建的是动态的变量,第三个创建的是const。看上去有很多相似之处,其实绑定...
ANSI Common Lisp 5 Data and Control Flow 5.3 Dictionary of Data and Control Flow 5.3.16 defparameter, defvar MacroSyntax:defparameter name initial-value [documentation] name defvar name [initial-value [documentation]] name Arguments and Values:...
给defparameter传入一个符号和一个值,来创造一个全局变量; defconstant创造一个全局常量。 CL-USER> (defparameter *glob* 99) *GLOB* CL-USER> (defconstant limit (+ *glob* 1)) LIMIT CL-USER> *glob* 99 CL-USER> limit 100 CL-USER>