[Swift-devel] iterate behaviour round II
Mihael Hategan
hategan at mcs.anl.gov
Wed Aug 3 00:22:21 CDT 2011
So I think we decided that:
iterate v {
trace(v);
} until (v >= 10);
would do the test after v was incremented and would always execute at
least once (so 0 to 9 would be printed).
But then the tutorial has the following (adapted a bit):
int a[]; a[0] = 10;
iterate v {
a[v + 1] = a[v] - 1;
} until(a[v+1] < 1);
It's all peachy in concept, except if v is incremented before the check,
an access to a[v+1] will hang. a[v] is now the correct expression in the
test, but then it's not quite intuitive.
Proposal 1: change documentation and tests to "until(a[v] < 1)" (this
does not solve the problem in general since a[v+1] would still lead to a
hang, not unlike bug 481
Proposal 2: Proposal 1 + deprecate iterate and suggest foreach instead.
Opinions? Other ideas?
Mihael
More information about the Swift-devel
mailing list