Hi,

Pattern matching happens when facts are asserted, retracted, or
modified. If you pattern-match against a defglobal, the only value
that is relevant is the defglobal's value at the time that the
matching facts are asserted (or are modified to match). If you later
change the value of the defglobal, nothing happens -- the match is not
invalidated.

The Jess manual explains this at the end of section 2.8.1. This is how
the Rete algorithm works. If you want a "global" that you can change
over time, use a fact instead. If you need to modify the fact from a
deffunction without matching it, then use a defquery!

Pattern-matching on globals has come up several times on this list
recently. Because of this behavior, however, it's simply not a very
useful concept. You can do it, but a fact will be generally more useful.

I think Alceu - UFSC/Labspot wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Thank you for your help and sorry for the mistake mixing the versions, but
> now I'm trying to construc a "generic" rule in order to be able to fire it
> from any modules through diferents facts, and I realised that global
> variable *DJ1* carry correct information to fire the rule, but it doesn't
> happen, i.e., the rule will be fired only as global variable is defined in
> defglobal.
> I know that (reset) could change global variable as stated in the Jess
> manual item 2.3, but in this case it looks different since I've confirmed
> the value of global variable before the module has been enabled tu run.
> I'd appreciate any suggestion,
> thanks,
> Alceu
> 
> My code sound like this:
> 
> (deftemplate MAIN::foo
> (slot id)
> (slot taste))
> 
> (defmodule BST)
> ;(defglobal ?*DJ1* = BISCUIT)
> (defglobal ?*DJ1* = CANDY)
> 
> (defrule MAIN::start
> =>
> (bind ?*DJ1* BISCUIT)
> (printout t "MAIN focus to BST *DJ1*=" ?*DJ1* crlf)
> (focus BST))
> 
> (defrule BST::change_global
> =>
>   (bind ?*DJ1* BISCUIT)
>   (printout t "*DJ1*=" ?*DJ1* " in BST" crlf)
>   (assert (fase fase2)))
> 
> (defrule BST::test
> ;  (foo(id BISCUIT) (taste VANILLA))
>   (foo(id ?*DJ1*) (taste VANILLA))
>   (fase fase2)
> 
> =>
>   (printout t "Rule Fired GLOBAL as: " ?*DJ1* crlf))
> 
> (reset)
> 
> (assert (foo(id BISCUIT) (taste VANILLA)))
> 
> (run)
> 
> 
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> Date: Quinta-feira, 25 de Abril de 2002 17:09
> Subject: Re: JESS: First use of variable negated
> 
> 
> >There were two different patches related to matching defglobals; both
> >have been applied in 6.1a1. Your code works fine for me in that
> >version, as seen in the dialog below, so maybe you've just got your
> >versions mixed up.
> >
> >Your alternate code with a local variable has completely different
> >semantics: it doesn't use the local you define at the top level, but
> >effectively creates a new ?DJ1 for use in pattern matching.
> >
> >----------------------------------------------------------------------
> >Jess, the Java Expert System Shell
> >Copyright (C) 2001 E.J. Friedman Hill and the Sandia Corporation
> >Jess Version 6.1a1 5/2/2002
> >
> >Jess> (deftemplate foo(slot id))
> >(defglobal ?*DJ1* = DJ1)
> >TRUE
> >Jess> TRUE
> >Jess> (defrule teste
> >?DJ_global <- (foo(id ?*DJ1*))
> >=>
> > (printout t "GLOBAL is" ?*DJ1* crlf)
> > )
> >TRUE
> >Jess> (reset)
> >(assert (foo(id DJ1)))
> >(run)TRUE
> >Jess> <Fact-1>
> >Jess>
> >GLOBAL isDJ1
> >1
> >Jess>
> >----------------------------------------------------------------------
> >
> >
> >I think Alceu - UFSC/Labspot wrote:
> >[Charset iso-8859-1 unsupported, filtering to ASCII...]
> >> I'm trying to fire a rule using in the LHS a global variable. Although
> I've
> >> fixed HasLHS.java ,Jess 6.0b1 version, as reported in the answer of
> Steve's
> >> e-mail,  Jess shows the message "First use of variable negated: ".
> >> I've tried Jess 6.1a1 binary code too, but the only way that I've found
> >> success is using local variable instead of global in the LHS.
> >> The code is like that:
> >>
> >> (deftemplate foo(slot id))
> >> (defglobal ?*DJ1* = DJ1)
> >>
> >> ;(bind ?DJ1 ?*DJ1*)
> >>
> >> (defrule teste
> >> ;?DJ_local <- (foo(id DJ1))
> >> ?DJ_global <- (foo(id ?*DJ1*))
> >> =>
> >>  (printout t "GLOBAL is" ?*DJ1* crlf)
> >>  )
> >>
> >> (reset)
> >> (assert (foo(id DJ1)))
> >> (run)
> >>
> >> Sorry if this subject has been discussed before.
> >>
> >> Thanks in advance,
> >> Alceu
> >>
> >> -----Original Message-----
> >> From: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> >> To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> >> Date: Sexta-feira, 1 de Mar_o de 2002 11:33
> >> Subject: Re: JESS: First use of variable negated
> >>
> >>
> >> >Hi Steve,
> >> >
> >> >This is a known regression in Jess 6.0; it was first reported by Simon
> >> >Hamilton. It's fixed in the next release, which should be next week.
> >> >
> >> >Here's a patch for 6.0: change line 189 in jess/HasLHS.java from
> >> >
> >> >        if (name.startsWith("*"))
> >> >            ;                    // <--- THIS LINE
> >> >
> >> >to
> >> >        if (name.startsWith("*"))
> >> >            continue;
> >> >
> >> >
> >> >I think Steve Webster wrote:
> >> >[Charset iso-8859-1 unsupported, filtering to ASCII...]
> >> >> All,
> >> >>
> >> >> I'm encountering a "First use of variable negated" error that I can
> not
> >> find
> >> >> an explanation for in the documentation or this list's mail archive.
> In
> >> >> summary, when first referencing a global variable in a predicate under
> >> Jess
> >> >> 6.0, a corresponding error is thrown.
> >> >>
> >> >> The offending code is:
> >> >>
> >> >> (defglobal ?*mti* = "Recon_PhaseLine")
> >> >>
> >> >> (deftemplate foo
> >> >>   (slot instanceName)
> >> >> )
> >> >>
> >> >> (defrule create-salute-report-state
> >> >>   (foo (instanceName ?*mti*))
> >> >> =>
> >> >>   (printout t "bar")
> >> >> )
> >> >>
> >> >> However, when I replace the predicate, "(foo (instanceName ?*mti*)),"
> >> with
> >> >> what I believe to be the equivalent, "(foo (instanceName ?i&:(eq ?i
> >> >> ?*mti*)))," no error results, and the clp file compiles.
> >> >>
> >> >> Given how basic this scenario is, I can not help but think I have
> missed
> >> >> something obvious. Can anyone tell me why the initial code gives an
> error
> >> on
> >> >> compilation?
> >> >>
> >> >> Thanks in advance for your help,
> >> >>
> >> >> Steve
> >> >>
> >> >>
> >> >> --------------------------------------------------------------------
> >> >> 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]
> >> >--------------------------------------------------------------------
> >> >
> >> >
> >>
> >>
> >>
> >> --------------------------------------------------------------------
> >> 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]
> >--------------------------------------------------------------------
> >
> >
> 
> 
> --------------------------------------------------------------------
> 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