Wave 4: add sequences/vectors/files chapters, 23 exercises, quiz3, finish ceremony, PCL table
This commit is contained in:
1 parent
77843402fa
commit
4675bd1106
76 files changed
+2505
-14
No files matched your search
@@ -0,0 +1,35 @@
|
||||
;;; DYNAMIC 4: DEFVAR VS DEFPARAMETER
|
||||
;;;
|
||||
;;; Both define a special variable. The difference shows when their
|
||||
;;; form runs AGAIN - a reload, say:
|
||||
;;;
|
||||
;;; DEFPARAMETER rebinds: the new value wins.
|
||||
;;; DEFVAR only fills an EMPTY variable: what is there stays.
|
||||
;;;
|
||||
;;; So DEFVAR suits state the code fills in over time; DEFPARAMETER
|
||||
;;; suits a constant you might retune. The file below runs both
|
||||
;;; forms twice, the way a reload would.
|
||||
|
||||
(defvar *cache* 10)
|
||||
(defparameter *config* 10)
|
||||
|
||||
;; The program grows the cache and retunes the config by hand:
|
||||
(setf *cache* 99)
|
||||
(setf *config* 99)
|
||||
|
||||
;; Re-evaluating the file, as a reload would:
|
||||
(defvar *cache* 10)
|
||||
(defparameter *config* 10)
|
||||
|
||||
;; TODO: The pair of values you see NOW.
|
||||
(defun current-values ()
|
||||
(list 10 10))
|
||||
|
||||
;;; ------------------------------------------------------------------
|
||||
;;; Checks. Read them - they tell you what to aim for - but leave
|
||||
;;; them unchanged.
|
||||
;;; ------------------------------------------------------------------
|
||||
|
||||
(check-equal '(99 10) (current-values))
|
||||
(check-equal 99 *cache*)
|
||||
(check-equal 10 *config*)
|
||||
Reference in new issue
Block a user