When the meaning of a method is interpreted, $0 is set equal to
the name of the event (this instance of execution of the method).
Likewise, when the meaning of a relation is interpreted, $0 is
set equal to the name of the infon (this instance of the relation
tuple).
This permits you to record customized information whenever the
meaning of the method or relation is interpreted.
Here is a simple example (suggested by Adrian Apollo) which
records explanations for the failures of the "increase" method.
# increase.mkr
# Aug/30/2005
# NumberList relations
precedes isu VERB with ctype=relation;
succeeds isu VERB with ctype=relation;
1 precedes 2; 2 succeeds 1;
2 precedes 3; 3 succeeds 2;
# ...
19 precedes 20; 20 succeeds 19;
increase iss method with
# Product = next number in NumberList
format=[number:1],
local=[y],
meaning={
set echo=off;
if $1 is nonexistent;
then y := nonexistent;
$0 has explanation = "fail($1): invalid input";
else
# precedes is faster than succeeds
#y := ? succeeds $1;
y := $1 precedes ? ;
if $y is [];
then y := nonexistent;
$0 has explanation = "fail($1): answer not in NumberList";
else $0 has explanation = "ok($1)";
fi;
fi;
set echo=on;
return Product=$y;
};
# test
x := do increase od 2 done;
y := do increase od 20 done;
z := do increase od nonexistent done;
every event isa increase {
$event has explanation=?;
};
increase_704 has explanation = "ok(2)";
increase_714 has explanation = "fail(20): answer not in NumberList";
increase_725 has explanation = "fail(nonexistent): invalid input";
Dick McCullough
knowledge := man do identify od existent done;
knowledge haspart proposition list;
http://rhm.cdepot.net/
Dick McCullough
knowledge := man do identify od existent done;
knowledge haspart proposition list;
http://rhm.cdepot.net/