using erroneous

Discussions related to Visual Prolog
Paul Cerkez
VIP Member
Posts: 388
Joined: 6 Mar 2000 0:01

using erroneous

Unread post by Paul Cerkez » 22 Oct 2010 15:51

Thomas,
I have created a few fact variables and initialzed them with erroneous.

my question is this, if the variable is still "erroneous" I want to take action on it and replace the erroneous with another value (could be an object ids, a populated tree, or what ever) that is not determined until runtime.

when I tried to use an if condition,

Code: Select all

input: neuron:= erroneous ... if input = erroneous then do ...
it would not compile, I would get an error back.

I created a workaround that works, but I would prefer to simply test on the 'erroneous' if possible.

any suggestions?
AI Rules!
P.

Gildas Menier
VIP Member
Posts: 78
Joined: 8 Jun 2004 23:01

Unread post by Gildas Menier » 22 Oct 2010 18:08

Hi Paul,

try

Code: Select all

 if isErroneous(input) then ...
best regards

Gildas

User avatar
Thomas Linder Puls
VIP Member
Posts: 2447
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls » 22 Oct 2010 21:40

erroneous is not a value, it is a state a fact variable can be in.

If you try to obtain the value of a fact which is in the erroenous state you will get an exception (your test obtains the value of the fact).

We have deliberately decided it like that because a value could "travel" far away before you noticed that it was in fact erroneous. This would lead to huge problems trying to trace back to the origin of the problem. The problem is well known from NULL pointers in languages that relies on such ones.

And as Gildas writes the solution is to use the special predicate isErroneous (which is special because it does not work on the value of the fact variable, but on the fact variable itself).
Regards Thomas Linder Puls
PDC

Paul Cerkez
VIP Member
Posts: 388
Joined: 6 Mar 2000 0:01

Unread post by Paul Cerkez » 23 Oct 2010 15:50

thanks Thomas and Gildas, I did not kow about the isErroneous predicate.

it defintiely solves my problem.
AI Rules!
P.

Post Reply