MKE 6.7 (Jul/31/2005) provides for local variables
in methods and relations. Local variables are useful
for avoiding name conflicts when executing nested
methods. Local variables are undefined outside of
the method or relation.
By default, MKR variables are global. To define
local variables, use the "local" attribute of the
method or relation. For example:
# KEHOME/test/local.ku
# Jul/31/2005
# test local variables in methods and relations
set debug=local;
do print od $count,$answer done;
add is method with
format=[number:1,number:2],
local=[count,answer],
meaning={
# simulate human method
set count = 0;
set answer = $1;
do print od $count,$answer done;
until $count is $2 {
count := do increase od $count done;
answer := do increase od $answer done;
do print od $count,$answer done;
};
set Product = $answer;
};
increase is method with
format=[number:1],
meaning={
# use MKE built-in method
do sum od $1,1 done;
};
# test
do add od 2,3 done;
do print od $count,$answer done;
Dick McCullough
knowledge := man do identify od existent done;
knowledge haspart proposition list;
http://rhm.cdepot.net/