chris319 wrote:
What is the overarching reason for requiring that the target of STEP be a constant?
@chris319: I have two quotes from the developers that throw some light on this topic.
Fred wrote:
Step (expression) is definitely a must have. I will try to implement it for the next version. Forget the DowTo stuff, I should be drunk
This quote was given Jan 27, 2004 in the thread [url]
http://www.purebasic.fr/english/viewtopic.php?f=3&t=928[/url]. If implemented this would have been accomplished in Version 3.90 .
freak wrote:
> But the While condition is dependent on whether the STEP value is positive or negative (this may not be known in advance)
It would be the same if the step supported variables.
This quote was given May 11, 2009 in the thread [url]
http://www.purebasic.fr/english/viewtopic.php?f=3&t=37400[/url].
It would seem from just these two quotes that Fred wanted to implement the idea at one point in time at least. It would also appear that when an expression is used for the step value a more complex condition is created for testing for the end of the loop.
Some discussion on aspects of the complexities can be found in the thread from 2009. It can be summed up by saying that with a variable start, stop, and step it would require a loop that tests for multiple situations in each iteration through the loop. If a constant is used then only one condition is tested for because it makes use of the sign of the step value at compile time.
I have a hope that it may still be implemented at some time in the future. In the meantime it can be accomplished with While/Wend or Repeat/Until loops.