I believe your temporary solution would only work if all Animal, Cat, etc.
objects were definstanced as an animal. This is an acceptable solution so
long as there is some base class that all objects can be definstanced to,
and you don't mind having to start all object pattern-matches using the base
class deftemplate. Once matched on the base class fact, 'test' can be used
to pattern-match on sub-class slots. However, some built-in features for
doing all this would be SO much appreciated!
Thanks for your help and for creating/maintaining Jess. It's awesome!
Alan Davis
CAD Research Center
California Polytechnic State University
San Luis Obispo, CA 93407
On Wed, 19 Aug 1998, Ernest Friedman-Hill wrote:
> 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.
>
---------------------------------------------------------------------
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]
---------------------------------------------------------------------