Eval fails in a simple defrule:
clips.Eval('(defrule duck (animal-is duck) => (assert (sound-is quack)))')
And the output:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/dist-packages/clips/_clips_wrap.py", line 149, in _WRAPPER
File "/usr/lib/python2.6/dist-packages/clips/_clips_wrap.py", line 238, in _WRAPPER
File "/usr/lib/python2.6/dist-packages/clips/_clips_wrap.py", line 4014, in Eval
_clips.ClipsError: C10: unable to evaluate expression
That's because you cannot use clips.Eval to define new rules. See Chapter 12.3.5 Evaluating a Function within a String in the CLIPS Basic Programming Guide.
… NOTE: eval does not permit the use of local variables (except when the local variables are defined as part of the command such as with an instance query function), nor will it evaluate any of the construct definition forms (i.e., defrule, deffacts, etc.). The return value is the result of the evaluation of the string (or FALSE if an error occurs). …
You should use the function Build instead. See 12.3.6 Evaluating a Construct within a String.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.