> I am writing scripted code for Pattern-Matching with Object Patterns
> which is in Basic Programming Guide.Here is the code
> Example 1
> The following rules illustrate pattern-matching on an object's class.
>
> (defrule class-match-1
> (object)
> =>)
> [OBJRTBLD5] Undefined class in object pattern (getting this error)
I don't get an error when I try the above. Is that really the code
that caused that error? You're not supposed to get that unless you've
specified an is-a constraint using an undefined class.
> Similarly,for code
>
> (defrule slot-match-1
> (object (width))
> =>)
> [OBJRTBLD2] No objects of existing classes can satisfy width
> restriction in object pattern.
>
> What is the actual problem? Why I am getting these errors?
It's perhaps not very clear in that BPG section but you have to define
a class that can match the constraints of the rule before defining the
rule. If you read the paragraph just after the examples it says "Rule
slot‑match‑1 is satisfied by all instances of reactive classes that
contain a reactive width slot with a zero length multifield value.
..."
CLIPS> (defrule slot-match-1
(object (width))
=>)
[OBJRTBLD2] No objects of existing classes can satisfy width
restriction in object pattern.
ERROR:
(defrule MAIN::slot-match-1
(object (width
CLIPS> (defclass Foo (is-a USER)
(multislot width))
CLIPS> (defrule slot-match-1
(object (width))
=>)
CLIPS>
HTH
Johan Lindberg
jo...@pulp.se
> Yes...i've posted worng code.I am also not getting any error in this
> code.Instead I am getting that error with this code ...
>
> (defrule class-match-2
> (object (is-a FOO))
> =>)
> [OBJRTBLD5] Undefined class in object pattern (getting this error).
>
> Now,how can i solve it?
Well, it's basically the same problem as with the other error-code.
You're referring to an undefined class (FOO). If you instead try:
CLIPS> (defclass FOO (is-a USER))
CLIPS> (defrule class-match-2
(object (is-a FOO))
=>)
CLIPS>
you don't get that error.
I noticed that my previous reply was missing a paragraph at the end
but I hope it was clear enough anyway. The point I was trying to get
across is basically that you cannot compile rules referring to
undefined classes. It works the same way as with (defined)
deftemplates.
HTH
Johan Lindberg
jo...@pulp.se