Step expression must be constant?

BlitzMax Forums/BlitzMax Beginners Area/Step expression must be constant?

I think it's also for compiler optimization actually, I seem to recall a discussion about this issue elsewhere (maybe for B3D).


I appreciate the performance improvements, but I really think that a potential optimisation is not a justification for such a language limitation.

Ideally, the compiler should see whether or not the step expression is constant or variable, and only add the additional code if it is variable. As long as the behaviour is well-documented, it shouldn't be a problem.

I believe such optimisations are the reason why case statements in some languages must be constant. I think that the compiler should look at the whole switch / select construct and if all of the case expressions are constant, it will produce specially optimised code, otherwise it will generate the equivilent of a series of if...elseif...endif statements.