<div dir="ltr">Hi<div><br></div><div>Could you please check this "Unhandled exception" and explain what is wrong</div><div>with my code</div><div><br></div><div><div>(defun var? (x)</div><div> (and (symbolp x) (not (keywordp x)) (eq (char (symbol-name x) 0) #\?)))</div>
<div><br></div><div>(defun vars-in (expr)</div><div> (if (atom expr)</div><div> (if (var? expr) (list expr))</div><div> (union</div><div> (vars-in (car expr))</div><div> (vars-in (cdr expr)))))</div>
<div><br></div><div>(defmacro aif (test-form then-form &optional else-form)</div><div> `(let ((it ,test-form))</div><div> (if it ,then-form ,else-form)))</div><div><br></div><div>(defun select! (pat) ; returns a list of bindings</div>
<div> (print pat)</div><div> '((it . (p b a)) (?x . 'b)))</div><div><br></div><div>(defmacro select-loop (pat &rest keywords-and-forms)</div><div> (let ((bind (gensym))</div><div> (vars (cons 'it (vars-in pat))))</div>
<div> `(block select-loop</div><div> (aif (select! ',pat)</div><div> (progn</div><div> (let ((binds it) ,@(mapcar #'list vars))</div><div> (declare (special ,@vars))</div>
<div> (loop for ,bind in binds</div><div> do (progn</div><div> (setf it (cdr (assoc 'it ,bind)))</div><div> ,@(mapcar #'(lambda (v) `(setf ,v (cdr (assoc ',v ,bind))))</div>
<div> vars))</div><div> ,@keywords-and-forms)))))))</div><div><br></div><div>(defmacro defrule (name args &rest body)</div><div> `(defmacro ,name ,args</div><div> (list 'let (list ,@(mapcar #'(lambda (x) `(list ',x `',,x)) args))</div>
<div> '(declare (special ,@args))</div><div> ,@(mapcar #'(lambda (x) `'(if (var? ,x) (makunbound ,x))) args)</div><div> ,@(mapcar #'(lambda (x) `',x) body))))</div><div><br></div><div>
(defrule ancestor (?x ?y)</div><div> (union</div><div> (select-loop (p ?x ?y) collect it)</div><div> (select-loop (p ?x ?z)</div><div> append (ancestor ?z ?y))))</div><div><br></div><div>? (ancestor ?x a)</div>
</div><div><br></div><div><div>Unhandled exception 10 at 0x28545, context->regs at #xb01641fc</div><div>Exception occurred while executing foreign code</div><div> at compact_dynamic_heap + 965</div><div>received signal 10; faulting address: 0xd360000 </div>
<div>? for help</div><div>[3422] Clozure CL kernel debugger: ?</div><div>(G) Set specified GPR to new value</div><div>(R) Show raw GPR/SPR register values</div><div>(L) Show Lisp values of tagged registers</div><div>(F) Show FPU registers</div>
<div>(S) Find and describe symbol matching specified name</div><div>(B) Show backtrace</div><div>(T) Show info about current thread</div><div>(M) Show memory areas</div><div>(X) Exit from this debugger, asserting that any exception was handled</div>
<div>(P) Propagate the exception to another handler (debugger or OS)</div><div>(K) Kill Clozure CL process</div><div>(V) Show Subversion revision information</div><div>(?) Show this help</div><div>[3422] Clozure CL kernel debugger: B</div>
<div>current thread: tcr = 0x2000f0, native thread ID = 0xbe03, interrupts enabled</div><div><br></div><div><br></div><div>Bogus frame 606b40</div><div>[3422] Clozure CL kernel debugger: L</div><div>[3422] Clozure CL kernel debugger:</div>
</div><div><br></div><div><br></div><div>Kind regards</div><div>Taoufik</div><div><br></div></div>