I am creating an expert system with Common Lisp for my research. There is a global variable: database BF →.
I initialize like this:
(defvar *BF* NIL)
My "main function" calls the "initialize" function, which sets a global variable with big data.
(defun initialize () (setf *BF* '( (metric ( (CPU-utilization NIL) (RPI NIL) (ART NIL) (concurent-invocation NIL) (stall-count NIL) (GC-bytes-in-use NIL) (available-thread NIL) (available-connection NIL) (instance-count NIL) )) (problem ( (livelock T) (memory-leaks T) (code-inefficient T) (overload T) (under-allocation T) (internal-chokepoint T) (thread-leaks T) (blocking-deadlock T) (unending-retries T) (overuse-external-system T) (pig-in-a-python T) (too-many-layers T) (backend-bottleneck T) (frequent-GC-resource-leaks T) (slow-backend T) (suddenly-slow-backend T) (nonblocking-deadlock T) (thread-leaks T) )) (category ( (sudden T) (consistent T) (periodic T) (progressive T) )) ) ) )
When using this function for the first time, when I type BF, this is normal. Then I call a function that modifies BF:
(defun apply-rule (type name value) ; Get conclusion list for this rule (let ((conclusion (get-conclusion name value))) (if (null conclusion) (if (not (equal 3 value)) (return-from appliquer-regle NIL) (return-from appliquer-regle 'T) ) ) ; Iterate on all problems in *BF* (dolist (e (cadr (assoc 'problem *BF*))) ; If the problem is not in conclusion list, set it value to false (if (and (member (car e) conclusion) (equal (cadr e) 'T)) () (setf (cadr e) NIL) ) ) (return-from apply-rule 'T) ) (return-from apply-rule NIL) )
This feature works. But when I want to use the "initialize" function again, it does not work. When I print BF, it contains the old values ... How to do to reinitialize my global variable?
Sorry for my English, I'm French ^
global-variables lisp
user1934665
source share