I'm sorry, I guess I was writing in a kind of shorthand -- should have
taken a bit more time. Of course, you can't have a bare function call
as a slot value in a pattern, and as you observed, you can't use a
function call at all in a backward-chaining pattern. I'd suggest that
you use a defglobal to hold the Class object, but matching to
defglobals is a little shaky in Jess 6.0. In the next release (which
I've been promising "any day now" for several weeks, sorry) matching
to defglobals will be fine, so that'd be one way to approach this.
I think Sander Faas wrote:
> Although I don't want to modify the objects in my ontology (as I mentioned
> in my previous message), I couldn't resist to put this principle aside in
> order to test if the trick works. The deftemplate of the have predicate now
> looks like this:
>
> "(deftemplate MAIN::have extends MAIN::__fact \"$JAVA-OBJECT$
> storyagents.storyworldontology.Have\"
> (slot class (default <External-Address:jess.SerializablePD>))
> (slot owner (default <External-Address:jess.SerializablePD>))
> (slot ownerType (default <External-Address:jess.SerializablePD>))
> (slot possession (default <External-Address:jess.SerializablePD>))
> (slot possessionType (default <External-Address:jess.SerializablePD>))
> (slot OBJECT (type 2048)))"
>
> The corresponding class:
> class Have implements Predicate
> {
> PhysicalObject possession;
> HumanBeing owner;
> Class possessionType;
> Class ownerType;
> }
>
> (The setPossession and setOwner methods of this class update the
> corresponding types by calling setPossessionType(possession.getClass()) and
> setOwnerType(owner.getClass()) respectively)
>
> Now when I try to perform the trick:
>
> (defrule test-rule
> (have (possessionType (class (call Class forName "Pencil"))))
> =>
> (printout t "I have a pencil" crlf)
> )
>
> I receive the error message "Bad slot value".
>
> When I try:
> (have (possessionType (call Class forName "Pencil")))
>
> the same error shows up, and:
> (have (possessionType ?pt&=(call Class forName "Pencil")))
>
> results in "Can't use funcalls in backchained patterns MAIN::have"
>
> Any ideas would be greatly appreciated.
>
> Sander
>
>
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]]On
> > Behalf Of [EMAIL PROTECTED]
> > Sent: dinsdag 19 maart 2002 20:11
> > To: [EMAIL PROTECTED]
> > Subject: Re: JESS: Backward chaining definstance facts
>
> <cut>
>
> > OK, anyway, the trick is to use
> >
> > (have (possession-type (class (call Class forName
> > "package.pencil"))))
> >
> > where you've got "(have (possession ?pencil <of type pencil>))"
> > below. Then the need-have fact should have the posession-type slot
> > filled in with the appropriate class object, which you can use to
> > synthesize the "pencil" object and "have" fact.
>
> <cut>
>
>
> --------------------------------------------------------------------
> 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]
--------------------------------------------------------------------