Of the couple of hundred programming languages I have
used, there is precisely one that does what you expect
(the S programming language, as implemented in R).
And it is a major pain in the posterior with no upside
that I can discern.
Suppose I want a sequence of n consecutive integers
beginning with 1.�� In Smalltalk, (1 to: n) does the
job.�� In R, 1:n *almost* does the job.�� But what
happens when n = 0?�� Smalltalk gives me the right
answer: an empty sequence.�� R gives me (1,0).�� That
means that *every* *flaming* *time* I write
for (i in 1:n) {...}
I have to take special care to ensure that n is not
0, sometimes even having to whack in an extra
if (n > 0) for (i in 1:n) {...}
Trawling through my Smalltalk code, I find that about
��6.8% of my counted loops are by: -1,
��0.7% of them are by: a negative number other than -1,
��2.5% of them are by: a positive number other than 1,
90�� % are just to:do: with no by:
Inspecting some of the 90% showed that many of them
would go catastrophically wrong if 1 to: 0 do:
performed its body