An instance of class while
executes it's while<-body
until it's while<-condition
fails, similar to the Pascal or C while statement.
While loops are rarely used in XPCE. Most loops in XPCE entails
enumerating the elements of a collection. For this purpose the methods chain->for_all, vector->for_all,
etc. are more appropriate. The following two examples both print all
elements of Chain to the standard output:
new(N, number(0)),
get(Chain, size, Max),
send(while(N < Max,
and(message(@pce, format, '%N\n',
?(Chain, nth0, N)),
message(N, plus, 1))),
forward)
Or
send(Chain, for_all,
message(@pce, format, '%N\n', @arg1))
new(and) and an always false as new(or).
<-body).<-body
while the while<-condition
holds.