@BeniBela
Using a enumerator, nice !
I hadn't thought of that.
@skalogryz:
Thanks for the correction as you are correct. Not much use for this simple case though but, i get your point.
Why to introduce a new keyword?
Well, it was the first thing that popped to mind. As minesadorada noticed correctly, i once started out with basic and some things seem to have survived my decaying brain-cells (that is, assuming i have any to begin with
).
Your idea/suggestion is just as valid.
And, introducing "step" might come in conflict with "downto".
Yes you are correct.
As a matter of fact that is enclosed in the Pascal for construction to begin with.
The moment downto was introduced it causes ambiguity. Some basic language variants solved that by interpreting the values.
Assuming the step value is a signed integer your solution suffers from that as well.
Probably reason why something like it was not implemented/supported already ?
But what algorithms require "step"? ... or is just for educational tasks?
It is just syntax sugar as things can be solved using other another approach.
However, support for something like this can make the life of a programmer a bit easier (or make the programmer more lazy, depending on how you look at it).
There is a reason why OP asked his/her question. Most likely because such construct was encountered in another language before looking at Pascal.
Although i dislike most suggestions made to improve the language because it really is syntax sugar alone or an attempt to whore the language itself, it is imo a bit strange to keep having to say no to someone asking such a question. Apparently there is an expectation that such a construct is available.
Even though the enumerator solution is able to solve that partly, it isn't a basic solution that a beginner would look at (i overlooked it as well)
But, i have a feeling that this discussion was made long before it was brought up here. I simply haven't looked at any of them yet. Would be nice to have some idea on the reason(s) why it was rejected (if any).