I'm assuming you mean -ordered- facts, the ones without slots. 

Actually, yes, you can do this with ordered facts, but you have to use
the "secret" of how ordered facts are implemented. You will presumably
want to define the inheritance before any facts of the relevant types
are asserted, so you'll need to create deftemplates for your ordered
facts by hand. Here's how it works: an ordered deftemplate is a
regular deftemplate with a single multislot named __data:

Jess> (assert (somefact))
<Fact-0>
Jess> (ppdeftemplate somefact)
"(deftemplate MAIN::somefact extends MAIN::__fact \"(Implied)\"
 (multislot __data))"  

If you create an ordered deftemplate yourself, then you can use it
assert ordered facts. Jess automatically hides multislots named
__data. Once you have defined a deftemplate, you can extend it with
another one:

Jess> (deftemplate foo (multislot __data))
TRUE
Jess> (deftemplate bar extends foo)
TRUE
Jess> (assert (bar))
<Fact-0>
Jess> (defrule rule-1 (foo) => (printout t foo crlf))
TRUE
Jess> (run)
foo
Jess>

OK?

I think Mark Nahabedian wrote:
> 
> Thanks.  Is there a way to do this with onordered facts?
> 
> 
> [EMAIL PROTECTED] writes:
>  > 
>  > I think Mark Nahabedian wrote:
>  > > 
>  > > I have several predicate/templates that share certain behavior.  I'd
>  > > like to exopress this through shared code...  Is there some way of
>  > > doing this in Jess?  For example, can I use a variable in the first
>  > > element of a template ...
>  > 
>  > This is a planned feature for Jess version 7, now on the drawing
>  > board. Until then, you can try using fact inheritance to factor out
>  > the common parts of your templates.
>  > 
>  > (deftemplate two-slotted-thing (slot a) (slot b))
>  > (deftemplate thing1 extends two-slotted-thing)
>  > (deftemplate thing2 extends two-slotted-thing)
>  > 
>  > (defrule do-something
>  > (two-slotted-thing (a 1) (b 2)) 
>  >  =>
>  > )
>  > 
>  > This rule would fire for both thing1 and thing2 facts.
> 
> 
> 
> --------------------------------------------------------------------
> 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]
--------------------------------------------------------------------

Reply via email to