Error [OBJRTBLD2] and Error [OBJRTBLD5]

139 views
Skip to first unread message

richa

unread,
May 14, 2008, 8:18:18 AM5/14/08
to CLIPSESG
Hi all,
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)

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?

Johan Lindberg

unread,
May 14, 2008, 9:07:45 AM5/14/08
to CLIP...@googlegroups.com
Hi,

> 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

richa

unread,
May 15, 2008, 1:37:05 AM5/15/08
to CLIPSESG
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?

On May 14, 6:07 pm, "Johan Lindberg" <johan.h.lindb...@gmail.com>
wrote:
> Hi,
>
> > 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

Johan Lindberg

unread,
May 15, 2008, 2:22:32 AM5/15/08
to CLIP...@googlegroups.com
Hi again,

> 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

richa

unread,
May 15, 2008, 5:53:05 AM5/15/08
to CLIPSESG
Thanks to you.It really helpful and guiding.

On May 15, 11:22 am, "Johan Lindberg" <johan.h.lindb...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages