« Return to Thread: JESS: Type precision causes duplicate facts

Re: JESS: Type precision causes duplicate facts

by Ernest Friedman-Hill :: Rate this Message:

Reply to Author | View in Thread


On Jun 8, 2009, at 9:18 PM, Brian Rogosky wrote:

> Hello,
> As part of testing the problem from my previous posting, I noticed a  
> strange duplication of facts when trying to create a fact with a  
> slot of FLOAT type. In one case I am specifying a decimal and the  
> other a whole number, but the number is otherwise the same.  I would  
> think only one fact would be created, but instead two are created  
> but with different float representations.  The values are equal  
> according to the = operator; however the eq operator returns false.

The whole number is an RU.INTEGER, and the float is an RU.FLOAT.  
Comparing with = returns true because they have the same value, but eq  
returns false because they're different data types.

Variables and slots are untyped in Jess; only values have types. The  
"type" slot qualifier is included only for backwards compatibility  
with CLIPS; in Jess, as in CLIPS, it doesn't actually prevent a value  
of another type from being added to the slot. It's more for  
documentation than anything else. It's definitely not like a variable  
declaration in Java.

>
> Is this behavior to be expected and intended by design?

Yes.


>  I would think the slot with type Float would automatically convert  
> all raw values to float and so only create one fact in the example  
> below.

Nope. 1 and 1.0 are two different values. When it matters, use "=" for  
comparison.


---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences          Phone: (925) 294-2154
Sandia National Labs
PO Box 969, MS 9012                            ejfried@...
Livermore, CA 94550                             http://www.jessrules.com





--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------

 « Return to Thread: JESS: Type precision causes duplicate facts