counting_pine wrote:I think it should just say that the order of these three activities is undefined:
- evaluating the start value
- evaluating the end value
- initialising the iterator
I would say that the most intuitive ordering is the one given above, but it would potentially require using a temporary variable to store the start value before the iterator is initialised.
Because FBC doesn’t perform them in the most intuitive order, I would say that well-written code should not make any assumptions about the ordering, and so it should avoid referring to the iterator when setting the start/end values.
This is indeed the most intuitive order, and the order that Eddie expected to see. Take this simple example:
Code: Select all
' print the ten values before and after the middle element:
Dim as double MyArray(0 To 100)
Dim as integer i
Randomize , 1
for i=0 to 100
for i=i-10 to i+10
print i, MyArray(i)
Using the iterator is not that exotic. The problem is the FB implementation, and I bet the authors simply did not reflect about this case; otherwise they would have used a temporary variable, as you suggest. There is no performance penalty since the initialisation is done outside the loop.