|Paolo Amoroso's weblog. Main interests: Lisp, astronomy (Moon), space exploration (Apollo and early manned programs)||Calendar of past entries | Related links|
Lisa rules check fact slot names, not CLOS accessors
I run across a misunderstanding in the behavior of the Lisa production rule language that took me several days of furious debugging for complete enlightenment. Rules check only fact slot names for matching, not CLOS accessors. This is particularly important when you reason over CLOS objects rather than Lisa templates. The documentation does mention slot names, but it was not completely obvious to me that you can use only slot names.
In other words, if you have a class definition like:
(defclass myclass () ((myslot :initarg :myslot :accessor myslot-of :initform 10)))you can define a rule like this, which uses the slot name
myslotrather than the accessor
(defrule myrule () (myclass (myslot 10)) => (format t "~&Fire!~%"))Symptoms of this problem are fact assertion and/or rule definition errors related to slots with
nilvalues passed to functions that expect non-
nilarguments, but you are reasonably sure the slots should have appropriate values.
|Copyright © 2006 by Paolo Amoroso
Created with BlogMax
|About Lisp | Practical Common Lisp (learn Lisp) | Planet Lisp (blog agregator) | Common Lisp Directory (software and resources) | Why Lisp?|