On Dec 21, 2007, at 6:30 AM, Henrique Lopes Cardoso wrote:
I just found a problem with pattern usage in rules. The following
code works fine in Jess 70p1, but does not work with 71b1.
Did I miss something in the change log?
The release notes mention this, although it's a bit cryptic:
----------------------
Variables not bound by Java patterns. The semantics of Java patterns,
introduced in Jess 7.0, have changed slightly. These patterns no
longer bind user-accessible variables to any slots they're used in.
To access slot values of facts matched by Java patterns, use the fact-
slot-value function or the jess.Fact.getSlotValue(java.lang.String)
method.
Dot notation. The "simplified" or "Java" patterns can now use a "dot
notation" to reference slots in other patterns. This powerful
capability greatly expands the usefulness of Java patterns and makes
auto-generating Jess code much easier. Futhermore, The notation "?
x.y" in procedural code will be interpreted as "slot y of the fact in
x".
------------------------
The corresponding manual section
http://herzberg.ca.sandia.gov/jess/docs/71/rules.html#patterns_simple
shows how this rule should be rewritten using the new dot notation:
(defrule teenager
?p <- (person {age > 12 && age < 20} (firstName ?name))
=>
(printout t ?name " is " ?p.age " years old." crlf))
---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
PO Box 969, MS 9012 [EMAIL PROTECTED]
Livermore, CA 94550 http://www.jessrules.com
--------------------------------------------------------------------
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]
--------------------------------------------------------------------