1) A LONG and an INTEGER do not match;

2) There's currently no way to write a long literal in Jess;

3) An INTEGER "1" and a LONG "1" print the same, so a slot that prints
as (value 1) may contain either a LONG or an INTEGER.

Your rule is matching below because the pattern "?v&~1" matches any
LONG. No LONG is an INTEGER whose value is 1. If you wrote instead
"?v&:(<> ?v 1)", to do the numeric comparision instead of the very
precise type-and-value comparison that matching normally does, then
you'd get the result you want.

I think Thomas Gentsch wrote:
> 
> Hello there,
> 
> I'm playing around with jess.Value objects as Java properties which are
> seen as fact slots in Jess.
> Now I have the problem, that rules don't match as expected. I don't
> completely understand the algorithm of how Jess determines the slot type
> here ... what would be the right way to do this?
> 
> Many thanks in advance,
>       tge
> 
> The class:
> =======================
> 
> public class Attr
> {
>   private String objName;
>   private Value value = null;
>   Rete rete = null;
> [...]
>   public Value getValue()
>   {
>     return value;
>   }
> 
>   public void setValue(Value v)
>   {
>     Value tmp = value;
>     value = v;
>     pcs.firePropertyChange("value", tmp, value);
>   }
> 
>   public void setValue(int v)
>   {
>     try
>     {
>       setValue(new LongValue(v));
>       // I also tried this: no change ...
>       // value = (new
> LongValue(v)).resolveValue(rete.getGlobalContext());
>     }
>     catch(JessException e){} 
>   }
> [...]
> 
> The Jess code:
> =======================
> 
> (defclass Attr Attr)
> (defrule match-attrs
>   (Attr (objName ?n) (value ?v&~1))
> =>
>   (printout t "**** There is an attr '" ?n "': " ?v crlf)
> )
> 
> What happens:
> =======================
> java -classpath .:/opt/Jess60a3/jess-6.1a3.jar m1
> MAIN::match-attrs: +1+1+1+t
>  ==> Focus MAIN
>  ==> f-0 (MAIN::initial-fact)
>  ==> f-1 (MAIN::idle)
>  ==> f-2 (MAIN::Attr (class <External-Address:java.lang.Class>) (objName
> "Schnaggel") (value 1) (OBJECT <External-Address:Attr>))
> ==> Activation: MAIN::match-attrs :  f-2
> FIRE 1 MAIN::match-attrs f-2
> **** There is an attr 'Schnaggel': 1
> 
> Here it says, that fact f-1 has '(value 1)' so in theory the rule must
> NOT match, but it does ... (???)
> 
> -- 
> 
>                  Thomas Gentsch
> 
> --------------------------------------------------------------------
> 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]
> --------------------------------------------------------------------
> 



---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9012                  [EMAIL PROTECTED]
PO Box 969                  http://herzberg.ca.sandia.gov
Livermore, CA 94550

--------------------------------------------------------------------
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]
--------------------------------------------------------------------

Reply via email to