I think Juraj Frivolt wrote:
> 
> I find this behaviour of jess (60b3) strange:
> 

Hmmm. Well, not sure what languages you're comparing it to. In C, the
behavior would be basically the same (except that, of course, in C
you'd have to declare the variables.) Both in C, and in Jess, the
global scope is special. If a variable doesn't exist in a local scope,
then the global scope is searched. In Jess, if the variable doesn't
exist in either the local or the global scope, then it's created in
the local scope. This isn't terribly surprising. 

If you investigate further, you'll find that the global scope is
indeed special; a function called from another function will never
(normally) affect the calling function's variables. I say "normally"
because a Java Userfunction can indeed change the caller's variables
if it wants to -- that's how control structures are implemented.

> 
> public void setVariable(String name, Value value) throws JessException
> {
>       //Hashtable ht = findVariable(name);
>       //if (ht == null)
>       Hashtable ht = getVariables();
>         ht.put(name, value);
> }
> 
> Does it touch something badly?

Well, yes actually, two things.  Now there are 1) no more global
variables (Not a hugely valuable feature, really, but a feature
nonetheless) and 2) the values of defglobals are now local to the
function that set them (a major bug.) Making defglobals work properly
is actually the reason that the code you've commented above is
there. The other "global variables" are just a side effect, one which
I periodically consider removing. Although it sounds like it, I'm
really not -defending- how Context works right now, just
explaining. The current behavior works and makes sense if you think
about it correctly.

> 
> Now about my last question. I call Jesp from a XML parser... To do
> this I need to have a  link with the parser...

The Jess parser is in line for a major overhaul for Jess 6.1. Stay
tuned for details. All sorts of customization will be possible.


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