Jess,

Not sure if this is known, have not seen much on the internal workings
of "modify". I'm concerned about this because it looks like modifying a
fact sometimes requires the equivalent of:

For each slot modified
{
    Retract the fact
    Set the slot
    Assert the fact
}

Although in 6.1p7 it appears that from the rules modify accepts multiple
slot/values and is optimized (whereas Rete offers only a single
slot/value at a time) and 7.0b3 seems to do the inefficient loop.

I have attached the following as a text file, if attachments are
allowed. Try it in 6.1p7 and 7.0b3:

(watch all)

(deffunction getValue (?fact ?slotname)
  (bind ?temp (fact-slot-value ?fact ?slotname))
  (if (eq ?temp nil) then (bind ?temp ""))
  (return ?temp)
)

(deftemplate FC
  (slot SQL_OPERATION (type STRING))
  (slot TRANS_STATE (type STRING))
  (slot TRANS_STATE_last (type STRING))
  (slot CTRLJOB_ID (type STRING))
  (slot CTRLJOB_ID_last (type STRING))
)

(defrule FC_last (declare (salience -100))
    ?event <- (FC (SQL_OPERATION ~""))
=>
    (modify ?event
        (CTRLJOB_ID_last (getValue ?event CTRLJOB_ID))
        (TRANS_STATE_last (getValue ?event TRANS_STATE))
        (SQL_OPERATION "")
    )
)

(defrule FC_fire
  ?cast <-
  (FC
   (SQL_OPERATION "UPDATE" | "INSERT")
   (TRANS_STATE "SI" | "MI" | "EI")
   (TRANS_STATE ?trans_state)
   (TRANS_STATE_last ~?trans_state)
   )
  =>
  (printout t "FC_fire" crlf)
  )

(assert
 (FC
  (SQL_OPERATION "INSERT")
  (TRANS_STATE "EI")
  (CTRLJOB_ID "foo")))

(run)

Attachment: fcasttest.clp
Description: fcasttest.clp

Reply via email to