Coverage report: /home/ellis/comp/core/std/macs/const.lisp
Kind | Covered | All | % |
expression | 20 | 39 | 51.3 |
branch | 7 | 10 | 70.0 |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; std/macs/const.lisp --- DEFINE-CONSTANT and friends
9
(defun %reevaluate-constant (name value test)
10
(if (not (boundp name))
12
(let ((old (symbol-value name))
14
(if (not (constantp name))
16
(cerror "Try to redefine the variable as a constant."
17
"~@<~S is an already bound non-constant variable ~
18
whose value is ~S.~:@>" name old))
19
(if (funcall test old new)
22
(error "~@<~S is an already defined constant whose value ~
23
~S is not equal to the provided initial value ~S ~
24
under ~S.~:@>" name old new test)
26
:report "Retain the current value."
29
:report "Try to redefine the constant."
32
(defmacro define-constant (name initial-value &key (test #'eql) documentation)
33
"Ensures that the global variable named by NAME is a constant with a value
34
that is equal under TEST to the result of evaluating INITIAL-VALUE. TEST is a
35
/function designator/ that defaults to EQL. If DOCUMENTATION is given, it
36
becomes the documentation string of the constant.
38
Signals an error if NAME is already a bound non-constant variable.
40
Signals an error if NAME is already a constant variable whose value is not
41
equal under TEST to result of evaluating INITIAL-VALUE."
42
`(defconstant ,name (%reevaluate-constant ',name ,initial-value ,test)
43
,@(when documentation `(,documentation))))