Hi,
I am considering rewriting my rules to maximize the use of the dot
notation in patterns.
For instance:
(deftemplate x (slot a) (slot b) (slot c))
(deftemplate y (slot a) (slot b))
(defrule r
?x <- (x (a ?a) (b ?b) (c 1))
?y <- (y (a ?a) (b ?b))
=>
(printout t ?y " matches " ?x crlf) )
(defrule r_
?x <- (x (c 1))
?y <- (y {a == x.a} {b == x.b})
=>
(printout t ?y " matches_ " ?x crlf) )
(deffacts f
(x (a 1) (b 2) (c 1))
(y (a 1) (b 2))
(y (a 10) (b 20)) )
(reset)
(facts)
(run)
The rule r_ highlights the only restriction applied to the x fact, which
is in slot c.
Are there any performance issues related to this approach, or is it ok
to use any of these approaches?
By the way, I was trying to use (y (a ?x.a) (b ?x.b)) inside the y
pattern, which does not work - as explained in section 6.2.1 of the Jess
manual, «when you refer to a pattern binding in a Java pattern, the "?"
variable indicator is omitted». And I suppose it must be used inside
curly-brace notation, since (y (a x.a) (b x.b)) does not work either.
However, I do not get any error, just an "unexpected" result, as the
slot matching is ignored in the first case (rule r_ fires twice) and
does not succeed in the second case (rule r_ does not fire)...
Thanks in advance,
Henrique
--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------