Jess71p2 22 - Global variable names must begin and end with...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
3. Jess Language Basics 14 Reading the value of a dotted variable results in a call to fact-slot-value , while using bind to set such a variable will result in a call to modify . Dotted variables are a great convenience and can make a lot of Jess code read more clearly. 3.7.2. Global variables (or defglobals) Any variables you create at the Jess> prompt, or at the "top level" of any Jess language program, are cleared whenever the reset command is issued. This makes them somewhat transient; they are fine for scratch variables but are not persistent global variables in the normal sense of the word. To create global variables that are not destroyed by reset , you can use the defglobal construct. (defglobal [?<global-name> = <value>]+)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Global variable names must begin and end with an asterisk. Valid global variable names look like ?*a* ?*all-values* ?*counter* When a global variable is created, it is initialized to the given value. When the reset command is subsequently issued, the variable may be reset to this same value, depending on the current setting of the reset-globals property. There is a function named set-reset-globals that you can use to set this property. An example will help. Jess&gt; (defglobal ?*x* = 3) TRUE Jess&gt; ?*x* 3 Jess&gt; (bind ?*x* 4) 4 Jess&gt; ?*x* 4 Jess&gt; (reset) TRUE Jess&gt; ?*x* 3 Jess&gt; (bind ?*x* 4) 4 Jess&gt; (set-reset-globals nil) FALSE Jess&gt; (reset) TRUE...
View Full Document

Ask a homework question - tutors are online