←back to thread

166 points todsacerdoti | 6 comments | | HN request time: 1.437s | source | bottom
Show context
seabass ◴[] No.44506423[source]
I love this sort of cs history. I’m also curious—why do we “throw” an error or “raise” an exception? Why did the for loop use “for” instead of, say, “loop”?
replies(7): >>44506448 #>>44506467 #>>44506568 #>>44506657 #>>44506785 #>>44506943 #>>44507014 #
titanomachy ◴[] No.44506467[source]
That's a great question. The first language I learned was python, and "for i in range(10)" makes a lot of sense to me. But "for (int i = 0; i < 10; i++)" must have come first, and in that case "for" is a less obvious choice.
replies(3): >>44506505 #>>44506536 #>>44506602 #
1. Dwedit ◴[] No.44506505[source]
BASIC had the FOR-NEXT loop back in 1964.

10 FOR N = 1 TO 10

20 PRINT " ";

30 NEXT N

C language would first release in 1972, that had the three-part `for` with assignment, condition, and increment parts.

replies(2): >>44506544 #>>44506971 #
2. zabzonk ◴[] No.44506544[source]
In Fortran, it is a do-loop :)
replies(1): >>44506646 #
3. bee_rider ◴[] No.44506646[source]
Fortran has grown a lot over time. If somebody said it don’t have a do loop in 196X, I wouldn’t be too surprised.

Really it’s just syntactic sugar, just use a goto.

replies(2): >>44506939 #>>44511900 #
4. pklausler ◴[] No.44506939{3}[source]
The entire point of Fortran was being an effective optimizing compiler for DO loops.
5. kahirsch ◴[] No.44506971[source]
This reminds me of a little bit of trivia. In very old versions of BASIC, "FORD=STOP" would be parsed as "FOR D = S TO P".

I found that amusing circa 1975.

6. bregma ◴[] No.44511900{3}[source]
FORTRAN IV, at least the version I used on the PDP-11 running RSX, did not have a DO-loop. Just IF and GO TO. But it did have both logical and arithmetic IF.