Lisa rules check fact slot names, not CLOS accessors - Lisp Propulsion Laboratory log

Lisp Propulsion Laboratory log

Paolo Amoroso's weblog. Main interests: Lisp, astronomy (Moon), space exploration (Apollo and early manned programs) Calendar of past entries | Related links xml

Lisa rules check fact slot names, not CLOS accessors

Sunday, July 30, 2006

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 myslot rather than the accessor myslot-of:
(defrule myrule ()
  (myclass (myslot 10))
  (format t "~&Fire!~%"))
Symptoms of this problem are fact assertion and/or rule definition errors related to slots with nil values passed to functions that expect non-nil arguments, but you are reasonably sure the slots should have appropriate values.

Copyright © 2006 by Paolo Amoroso

Created with BlogMax

July 2006
Mon Tue Wed Thu Fri Sat Sun
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
Jun  Aug
About Lisp | Practical Common Lisp (learn Lisp) | Planet Lisp (blog agregator) | Common Lisp Directory (software and resources) | Why Lisp?