gudeman@CS.ARIZONA.EDU (David Gudeman) (05/03/90)
This problem with reversible assignment is part of a larger problem
that a lot of people seem to have with Icon. That is the problem of
understanding where backtracking "goes". In particular, the
reversible assignment problem seems to be caused by the following
misunderstanding:
global x
procedure foo()
x <- 1
suspend x
end
procedure main()
every foo()
end
where people think that when foo gets resumed, that resumes every
expression in foo that suspended in the past. But once you pass the
semi-colon (an implicit one in this case) the expression before the
semicolon is no longer suspended, it is finished. Here is a good test
for what expressions in a procedure can be resumed after a suspend:
imagine what would happen if you replaced
suspend EXPRESSION
with
every write(image(EXPRESSION))
basically, the sequence that would be written is the sequence that a
calling procedure would see. Also, any backtracking that would be
done between written values gets done between real suspensions. If
you wrote
procedure foo()
x <- 1
every write(image(x))
end
from above, would the assignment ever get reversed?