I think [EMAIL PROTECTED] wrote:
> 
> I have many "definstance" type shadow facts that correspond to java
> objects. I need to use rules to detect facts and then call Java
> methods with the facts as arguments.
> 
> Here is a simplified example of how I'm doing it now:
> 
> (defrule foo
>        (bar (property1 5) (OBJECT ?factO))
>       =>
>       (call ?*BOUND_OBJECT* baz ?factO))
> 
> It works, but it feels like a bit of a kludge. I only discovered the
> "OBJECT" slot by looking around at internals. This usage is not
> documented anywhere. Is this an "approved" method of getting objects
> out?

*** Yes, it is. The Jess 5.0 manual does document the existence of this
*** slot. Also, the "pumps" example uses this technique to adjust the
*** rate of the Pump objects.

> 
> It seems that it would be cleaner to say:
> 
>        ?fact <- (bar (property1 5))
>       =>
>       (call ?*BOUND_OBJECT* ?fact)
>       
> but, of course, fact in this case is bound to the fact-id, not the
> external address object.

*** The current architecture makes the nature of a fact (definstance
*** or not) transparent, which makes it easy to change this over time;
*** and indeed, using definstance/deftemplate inheritance (a 5.0
*** feature) a given rule might be operating on both kinds of facts at
*** different times. 

*** The idea that the "shadow fact" and the matched object are
*** separate things seemed to me, in the final analysis, an important
*** one to make explicit. This is certainly different than how COOL
*** works in CLIPS, but in that case the COOL objects have no separate
*** existence outside of CLIPS. In Jess, using Beans, the Beans can
*** exist both before and after their association with a Jess engine.

> I also had this problem with plain facts --
> there doesn't seem to be any straightforward way to "export" a fact to
> a Java function call as a ValueVector. After matching it on the
> LHS, all you have is a fact-id.
> 
> I'm wondering if there is a Jess function I don't know about that
> takes a fact-id and returns the fact it refers to. If there isn't,
> this seems like a desirable thing to have -- is there some other way
> to accomplish the same goal? I noticed that findFactByID is public in
> the Rete class, but its usage is also not documented and there are
> some warnings associated with it.

*** The only warning is that as you get back an actual handle to the
*** actual fact object, you must not change any of the slot
*** values. You're certainly welcome to use that function. In fact,
*** you can even use it from Jess code, by way of the (engine) function:

***        (call (engine) findFactById ?fact-id)

*** In Jess 5.0, there's a (fact-slot-value) function that will fetch
*** the value of a named slot from a particular fact; I've previously
*** published a Jess 4 version of this on this list (see the mailing
*** list archives if you're interested.)

*** But I should point out that in most cases this isn't the right
*** thing to do; it's not the proper way to do rule-based
*** programming. Matching the necessary slots on the rule LHS is
*** better. 


> Personally, I'd rather have this
> conversion happen inside of Jess -- fact-ids should be its problem,
> not the application programmer's. I might contribute such a thing
> (gotta love that open source model), but would like to understand the
> issues involved a bit better before I do.
> 
> Any thoughts on this question appreciated.
> 
> -- 
> 
> robin
> =:-{)
> University of California, Irvine
> Information and Computer Science Dept.
> 
> http://www.ics.uci.edu/~burke/
> 
> "The universe is made of stories, not of atoms" - Muriel Rukeyser


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
Org. 8920, MS 9214                  [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