Please read §6. Variables from Practical General Lisp .
Emacs Lisp, Common Lisp (Emacs Lisp ). (.. ) , , , ( "" ), *standard-output*
. defparameter
defvar
, . , ; , setf
Common Lisp: num2
; , , / - .
, , : , let
:
(let ((*standard-output* *error-output*))
(print "Stream redirection"))
print
, *standard-output*
; , *error-output*
. let
, *standard-output*
(, ).
, , ( ), : ( ) let
:
(let ((closure
(let ((count 0))
(lambda () (print (incf count))))))
(funcall closure)
(funcall closure))
;; prints:
;; 1
;; 2
lambda
, count
. , , count
. , .
MAPCAR
, ?
; , mapcar
, , , ( ):
(mapcar (lambda (x y) (* x y))
'(1 2 3)
'(0 3 6))
=> (0 6 18)
(mapcar
=> ((1 a +) (2 b /))
.
...
(defun adder (x)
(lambda (y) (+ x y)))
(mapcar (adder 10) '(0 1 2))
=> (10 11 12)
adder
x
, y
(+ x y)
.
...
, :
(defparameter *default-offset* 0)
... :
(defun offset (x)
(+ x *default-offset*))
mapcar
:
(let ((*default-offset* 20))
(mapcar #'offset '(1 2 3)))
=> (21 22 23)
jkiiski , (declare (special ...))
, ( let
, a defun
,...). progv
. "" , . .