Hmmm. That's a good point. Things are designed so that they'll work
with the classes you describe and only -one- defclass; Dogs and Cats
and Animals can coexist, but they'd all have the same slots and all be
called 'animals'.

I smell a new feature... I'll have a look and see if it's simple
enough that I can implement it quickly and include it in 4.1b6; else
it'll have to wait for the release after.

OTOH, for now, you could use the 'class' slot. Every definstance
object gets a 'class' slot from the 'getClass' method. You could match
a Cat as

  (animal (class (call java.lang.Class forName "Cat")) (fur "grey") ...)

You could streamline this by storing the Cat class object in a
defglobal named ?*cat* - then it would look like

  (animal (class ?*cat*) (fur "grey") ...)

Now, if you also wanted to match on a cat-specific slot, you could
bind the OBJECT slot to a variable and use the (get) function to
retrieve slots and test them... kinda messy, but it'd work.

But the syntactically nicer version you suggest should make it into a
future version! THanks for the idea.


I think alan davis wrote:
> 
> Yes, I understand the VERY nice feature of 'shadowing' Java Beans as
> deftemplates (unordered facts) and then pattern-matching on the facts.
> 
> However, how do you match on a generalized fact/Java Bean? For 
> example, suppose I have a Java Bean named Animal for which I specify
> '(defclass animal Animal)'. I then have other Java Beans which
> inherit from Animal (e.g. Dog, Cat) for which I provide similar
> defclass statements. Then if I provide definstances for Animal, Dog
> and Cat Java Bean objects, how do I pattern-match on any kind of
> Animal? A pattern such as "(animal ... (OBJECT ?obj))" won't work
> since it only matches instances of the base class Animal.
> 
> I realize I'm probably missing something obvious, but I could sure use
> a point in the right direction!
> 
> Thanks again,
>                              Alan Davis
>                          CAD Research Center
>                California Polytechnic State University
>                       San Luis Obispo, CA 93407
> 
> 
>  On Tue, 18 Aug 1998, Ernest Friedman-Hill wrote:
> 
> > Hi Alan,
> > 
> > Instead of supporting COOL, Jess supports pattern-matching on Java
> > Beans. You therefore have the entire Java language at your disposal,
> > including inheritance. Instead of creating COOL classes and instances
> > you create Java classes and objects.
> > 
> > I think alan davis wrote:
> > > 
> > > I just jumped on this user group, so forgive me if this question has
> > > already been asked...
> > > 
> > > I'm attempting to port COOL defrules to Jess and am looking for a way
> > > to pattern match on objects in a COOL-like fashion. Specifically, I
> > > need inheritance on the LHS (e.g. "(object (is-a <class>) ...)" ).
> > > Since Jess does not directly support this (as does COOL), I was
> > > hoping someone has already implemented a nice workaround.
> > > 
> > > Thanks in advance!
> > > 
> > >                              Alan Davis
> > >                          CAD Research Center
> > >                California Polytechnic State University
> > >                       San Luis Obispo, CA 93407
> > > 
> > > ---------------------------------------------------------------------
> > > To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> > > in the BODY of a message to [EMAIL PROTECTED], NOT to the
> > > list. List problems? Notify [EMAIL PROTECTED]
> > > ---------------------------------------------------------------------
> > > 
> > > 
> > 
> > 
> > ---------------------------------------------------------
> > Ernest Friedman-Hill  
> > Distributed Systems Research        Phone: (510) 294-2154
> > Sandia National Labs                FAX:   (510) 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. List problems? Notify [EMAIL PROTECTED]
> > ---------------------------------------------------------------------
> > 
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list. List problems? Notify [EMAIL PROTECTED]
> ---------------------------------------------------------------------
> 
> 


---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (510) 294-2154
Sandia National Labs                FAX:   (510) 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. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------

Reply via email to