I understand what it is that you want to do, and I agree that it
sounds like a useful idea, but unfortunately it's not part of the
modules concept in Jess (or in CLIPS.)  I thought about this for a
while, but I don't believe there's any way to get the effect you want
directly. You're left with the option of writing rules like
printBasicAndAI as

   (defrule printBasicAndAI
        (or (SUB::vocab (word ?v))
            (MAIN::vocab (word ?v)))
        =>
        (printout t "BasicAI " ?v crlf))

i.e., explicitly naming each type of template, and matching them each
explicitly.


I think DeGreef, Chris J. (AIT) wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Ernest, I forgot to mention in my first post that I am very impressed with
> JESS.  That probably did not come through in my last post with my "matter of
> fact" way of saying things.  I have always been interested in AI.  Now I
> have a business reason to use it AND a good (and reasonably priced)
> development tool (Jess) in which to work.  (sigh, sorry for the long post)
> 
> I agree: Jess is working as documented, and my attached post was obviously
> based on my misunderstanding of the relavent section of the manual.  But I
> am uncertain how to accomplish the following given how I understand the
> manual.  There are lots of reasons for asking this but I only mention one in
> an attempt to be clear and concise.
> 
> How do I assert local additions to a MAIN:: template without having those
> facts firing rules in other modules when those modules get focus?  Keep in
> mind that I want to write rules in each module that will fire on the union
> of the MAIN:: facts and the local additions. (And I don't know how I would
> write that kind of rule without duplicating the rules.)  What am I missing?
> 
> This is an example of what I tried to say in english.  I understand why all
> of the facts are printed from each rule.  Basically, I need more control
> over this.
> 
> (deftemplate vocab (slot word))
> (deffacts basicvocab
>       (vocab (word the))
>       (vocab (word a))
> )
> (defrule test
>       => (focus aiUser ooUser)
> )
> (defrule printBasic
>       (vocab (word ?v))
>       =>
>       (printout t "Basic " ?v crlf)
> )
> (defmodule aiUser)
> (deffacts aiJargon
>       (vocab (word assert))
>       (vocab (word backward-chaining))
> )
> (defrule printBasicAndAI
>       (vocab (word ?v))
>       =>
>       (printout t "BasicAI " ?v crlf)
> )
> (defmodule ooUser)
> (deffacts ooJargon
>       (vocab (word hierarchy))
>       (vocab (word encapcilation))
> )
> (defrule printBasicAndOO
>       (vocab (word ?v))
>       =>
>       (printout t "BasicOO " ?v crlf)
> )
> 
> A previous post indicates a CLIPS feature for importing facts into modules
> was left out to make Jess easier for us newbies.  Is that the feature I am
> looking for?
> 
> Could something like the following take its place?  Actually, link/copy
> could provide for "by reference" and "by value" variations.
> 
> (deftemplate foo (slot bar))
> (defmodule sub)
> (deftemplate foo (slot bar) (link MAIN))
> 
> Chris
> 
> -----Original Message-----
> From: Ernest Friedman-Hill [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 26, 2001 7:02 PM
> To: DeGreef, Chris J. (AIT)
> Cc: '[EMAIL PROTECTED]'; 'Chris at home'
> Subject: Re: JESS: modules and facts
> 
> 
> Hi Chris,
> 
> I'm actually rather happy with how this works -- let me try to clarify 
> what's happening for you.
> 
> "DeGreef, Chris J. (AIT)" wrote:
> > 
> > (deffact somefacts
> >         (head1 abc))
> > is asserted as (MAIN::head1 abc)
> > 
> > (defmodule SUB)
> > (deffact SUB::somemorefacts
> >         (head1 def))
> > is also asserted as (MAIN::head1 def)
> > 
> > Shouldn't the latter be asserted as (SUB::head1 def)?
> 
> The behaviour actually depends on whether or not MAIN::head1 or
> SUB::head1 were previously defined. If the template MAIN::head1 exists, but
> SUB::head1 does not, then the fact is created in MAIN, as you observe. But
> if
> SUB::head1 already exists, or if neither SUB::head1 nor MAIN::head1 exists,
> then the fact is a SUB::head1 fact.
> 
> > In fact, it only gets asserted in the module only when specified like
> > (deffact SUB::somemorefacts
> >         (SUB::head1 def))
> 
> As stated above, this isn't quite true.
> 
> > 
> > More specifically, any facts in the deffact statement, defined before a
> fact
> > definition referencing a module, are asserted to the MAIN:: module.  All
> > facts after a specific module fact are asserted to that same specific
> > module.
> 
> Again, that's not quite it; the facts end up in MAIN -only- if the necessary
> template
> already exists in the MAIN module.
> 
> > 
> > Effectively, all deffacts, regardless of the defmodule they follow, by
> > default extend the MAIN:: repository of facts and are accessable to all
> > modules.  This is unlike the assert statement, when executed in a module,
> > which asserts the fact with the <module>:: prefix on the fact as a
> default.
> > 
> 
> No, (assert) follows exactly the same rules -- the same code is used to do
> the template lookup.
> 
> 
> > I have a related question about modules and the scope of facts.
> > 
> > If the same fact head is defined in both modules, like ...
> > 
> >         (deffact MAIN::somefacts
> >                 (head1 abc)
> >         ...
> >         (deffact SUB::someotherfacts
> >                 (SUB::head1 def)
> > 
> > then a rule in module SUB will not fire with the (head1 abc) fact.  As
> in...
> > 
> >         (defrule SUB:rule1
> >                 (head1 ?a)
> >                 =>
> >                 (printout t ?a crlf))
> > 
> > This only prints "def".
> > 
> > Shouldn't the facts defined as MAIN:: be accessable to all modules even
> when
> > the names of the facts are the same?
> > 
> 
> MAIN::head1 and SUB::head1 are two different templates -- patterns can only
> match one or the other. Which one they match is decided when the rule is
> compiled.
> The first pp of mainual section 2.10.2 is pretty clear about this.
> 
> 
> 
> ---------------------------------------------------------
> 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]
> ---------------------------------------------------------------------
> 



---------------------------------------------------------
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